def build(filename): client = MetadataClient() u, p, ip = utils.retrieve_credentials() ip = True if ip == 'True' else False client.login(u, p, is_production=ip) if os.path.exists('.build'): shutil.rmtree('.build/') os.mkdir('.build/') print "kc" print filename name, type = (filename.split(".")) utils.build_package(name, type, '.build/') metadata_dir = utils.METADATA_DIRS.get(type, None) os.mkdir('.build/' + metadata_dir) src_dir = 'src/' + metadata_dir + '/' + filename bld_dir = '.build/' + metadata_dir + '/' if type in utils.CODE_FILES: for file in glob.glob(src_dir + "*"): shutil.copy(file, bld_dir) else: shutil.copyfile(src_dir, bld_dir) zip('.build') deploy_request = client.deploy('deploy.zip') while True: deploy_status = client.check_deploy_status(deploy_request.id) if deploy_status.done: break else: print deploy_status.status time.sleep(3) deploy_response = client.check_deploy_status(deploy_request.id) print deploy_response print "Deployment %s %s" % (deploy_response.id, deploy_response.status)
def deploy(): client = MetadataClient() u, p, ip = utils.retrieve_credentials() client.login(u, p, is_production=p) zip('src/') deploy_request = client.deploy('deploy.zip') while True: deploy_status = client.check_deploy_status(deploy_request.id) if deploy_status.done: break else: print deploy_status.status time.sleep(3) deploy_response = client.check_deploy_status(deploy_request.id) print "Deployment %s %s" % (deploy_response.id, deploy_response.status)
def retrieve(filename, dir='src/'): client = MetadataClient() u, p, ip = utils.retrieve_credentials() ip = True if ip == 'True' else False client.login(u, p, is_production=ip) if not os.path.exists(dir): os.mkdir(dir) name, type = (filename.split(".")) utils.build_package(name, type, dir) retrieve_request = client.retrieve(dir + 'package.xml') while client.check_status(retrieve_request.id)[0].done == False: pass retrieve_response = client.check_retrieve_status(retrieve_request.id) binary_to_zip(retrieve_response.zipFile) shutil.move('retrieve.zip', dir + 'retrieve.zip') os.system('unzip -uo ' + dir + '/retrieve.zip -d ' + dir)
def retrieve_package(dir='src/'): ################################################# ##### Retrieve the contents specified of a ###### ##### package.xml in the src directory ########## ################################################# client = MetadataClient() u, p, ip = utils.retrieve_credentials() ip = True if ip == 'True' else False client.login(u, p, is_production=ip) if not os.path.exists(dir): os.mkdir(dir) retrieve_request = client.retrieve(dir + 'package.xml') while client.check_status(retrieve_request.id)[0].done == False: pass retrieve_response = client.check_retrieve_status(retrieve_request.id) binary_to_zip(retrieve_response.zipFile) shutil.move('retrieve.zip', dir + 'retrieve.zip') os.system('unzip -uo ' + dir + '/retrieve.zip -d ' + dir)