def update_project_dir(): logger.debug('unzipping ' + MPK_FILE + ' to ' + INCOMING_MPK_DIR) subprocess.check_call(('rm', '-rf', INCOMING_MPK_DIR)) buildpackutil.mkdir_p(INCOMING_MPK_DIR) subprocess.check_call(('unzip', '-oqq', MPK_FILE, '-d', INCOMING_MPK_DIR)) new_mpr = os.path.basename(buildpackutil.get_mpr_file_from_dir( INCOMING_MPK_DIR)) existing_mpr_path = buildpackutil.get_mpr_file_from_dir(PROJECT_DIR) if existing_mpr_path: existing_mpr = os.path.basename(existing_mpr_path) else: existing_mpr = None logger.debug('rsync from incoming to intermediate') if buildpackutil.get_buildpack_loglevel() < logging.INFO: quiet_or_verbose = '--verbose' else: quiet_or_verbose = '--quiet' subprocess.call(( 'rsync', '--recursive', '--checksum', '--delete', INCOMING_MPK_DIR + '/', INTERMEDIATE_MPK_DIR + '/', )) logger.debug('rsync from intermediate to project') if new_mpr == existing_mpr: update_or_delete = '--update' else: update_or_delete = '--delete' subprocess.call(( 'rsync', '--recursive', update_or_delete, quiet_or_verbose, INTERMEDIATE_MPK_DIR + '/', PROJECT_DIR + '/', ))
def build(): mpr = os.path.abspath(buildpackutil.get_mpr_file_from_dir(PROJECT_DIR)) response = requests.post( 'http://localhost:6666/build', data=json.dumps({ 'target': 'Deploy', 'projectFilePath': mpr, 'forceFullDeployment': False }), headers={'Content-Type': 'application/json'}, timeout=120, ) if response.status_code != requests.codes.ok: raise MxBuildFailure("MxBuild failure", response.status_code, response.json()) result = response.json() if result['status'] == 'Success': try: sync_project_files() logger.info("Syncing project files ...") except: logger.warning("Syncing project files failed: %s", traceback.format_exc()) raise else: logger.warning("Not syncing project files. MxBuild result: %s", result) return result
def update_project_dir(): logger.debug("unzipping " + MPK_FILE + " to " + INCOMING_MPK_DIR) subprocess.check_call(("rm", "-rf", INCOMING_MPK_DIR)) buildpackutil.mkdir_p(INCOMING_MPK_DIR) subprocess.check_call(("unzip", "-oqq", MPK_FILE, "-d", INCOMING_MPK_DIR)) new_mpr = os.path.basename( buildpackutil.get_mpr_file_from_dir(INCOMING_MPK_DIR) ) existing_mpr_path = buildpackutil.get_mpr_file_from_dir(PROJECT_DIR) if existing_mpr_path: existing_mpr = os.path.basename(existing_mpr_path) else: existing_mpr = None logger.debug("rsync from incoming to intermediate") if buildpackutil.get_buildpack_loglevel() < logging.INFO: quiet_or_verbose = "--verbose" else: quiet_or_verbose = "--quiet" subprocess.call( ( "rsync", "--recursive", "--checksum", "--delete", INCOMING_MPK_DIR + "/", INTERMEDIATE_MPK_DIR + "/", ) ) logger.debug("rsync from intermediate to project") if new_mpr == existing_mpr: update_or_delete = "--update" else: update_or_delete = "--delete" subprocess.call( ( "rsync", "--recursive", update_or_delete, quiet_or_verbose, INTERMEDIATE_MPK_DIR + "/", PROJECT_DIR + "/", ) )
def build(): logger.debug('unzipping ' + MPK_FILE + ' to ' + INCOMING_MPK_DIR) subprocess.check_call(('rm', '-rf', INCOMING_MPK_DIR)) buildpackutil.mkdir_p(INCOMING_MPK_DIR) subprocess.check_call(('unzip', '-oqq', MPK_FILE, '-d', INCOMING_MPK_DIR)) logger.debug('rsync from incoming to intermediate') if buildpackutil.get_buildpack_loglevel() < logging.INFO: quiet_or_verbose = '--verbose' else: quiet_or_verbose = '--quiet' subprocess.call(( 'rsync', '--recursive', '--checksum', '--delete', INCOMING_MPK_DIR + '/', INTERMEDIATE_MPK_DIR + '/', )) logger.debug('rsync from intermediate to project') subprocess.call(( 'rsync', '--recursive', '--update', quiet_or_verbose, INTERMEDIATE_MPK_DIR + '/', PROJECT_DIR + '/', )) mpr = os.path.abspath(buildpackutil.get_mpr_file_from_dir(PROJECT_DIR)) response = requests.post( 'http://localhost:6666/build', data=json.dumps({ 'target': 'Deploy', 'projectFilePath': mpr, 'forceFullDeployment': False }), headers={'Content-Type': 'application/json'}, timeout=120, ) response.raise_for_status() for name in ('web', 'model'): subprocess.call(( 'rsync', '-a', os.path.join(DEPLOYMENT_DIR, name) + '/', os.path.join(ROOT_DIR, name) + '/', )) return response.json()
def build(): mpr = os.path.abspath(buildpackutil.get_mpr_file_from_dir(PROJECT_DIR)) response = requests.post( "http://localhost:6666/build", data=json.dumps( { "target": "Deploy", "projectFilePath": mpr, "forceFullDeployment": False, } ), headers={"Content-Type": "application/json"}, timeout=120, ) if response.status_code != requests.codes.ok: raise MxBuildFailure( "MxBuild failure", response.status_code, response.json() ) result = response.json() if result["status"] == "Success": try: sync_project_files() logger.info("Syncing project files ...") except Exception: logger.warning( "Syncing project files failed: %s", traceback.format_exc() ) raise try: send_metadata_to_cloudportal() except Exception: logger.warning( "Failed to send instadeploy feedback to Cloud Portal", exc_info=True, ) else: logger.warning("Not syncing project files. MxBuild result: %s", result) return result
def get_mpr_file(): return buildpackutil.get_mpr_file_from_dir(BUILD_DIR)