How to use the pybatfish.util.util.zip_dir function in pybatfish

To help you get started, we’ve selected a few pybatfish examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github batfish / batfish / projects / pybatfish / pybatfish / client / commands.py View on Github external
def bf_init_testrig(dirOrZipfile, doDelta=False, testrigName=None):
    '''
    Initialize a new testrig
    '''

    fileToSend = dirOrZipfile
    
    if (os.path.isdir(dirOrZipfile)):
        tempFile = tempfile.NamedTemporaryFile()
        batfishutils.zip_dir(dirOrZipfile, tempFile)
        fileToSend = tempFile.name

    if (bf_session.container is None):
        bf_init_container()

    if (testrigName is None):
        testrigName = Options.default_testrig_prefix + batfishutils.get_uuid()
    
    jsonData = workhelper.get_data_upload_testrig(bf_session, testrigName, fileToSend)
    resthelper.get_json_response(bf_session, CoordConsts.SVC_UPLOAD_TESTRIG_RSC, jsonData)
    
    if (not doDelta):
        bf_session.baseTestrig = testrigName
        bf_session.baseEnvironment = BfConsts.RELPATH_DEFAULT_ENVIRONMENT_NAME
        bf_logger.info("Base testrig/environment is now set to %s/%s", bf_session.baseTestrig, bf_session.baseEnvironment)
    else: