def test_export(toolchain, target, expected_error=None): if toolchain is None and target is None: base_dir = join(TEMP, "zip") else: base_dir = join(TEMP, toolchain, target) temp_dir = join(base_dir, "temp") mkdir(temp_dir) zip_path, report = export(USER_PRJ, USR_PRJ_NAME, toolchain, target, base_dir, temp_dir, False, fake_build_url_resolver) if report['success']: export_name = join(TEMP, "export_%s_%s.zip" % (toolchain, target)) cmd(["mv", zip_path, export_name]) print "[OK]" else: if expected_error is None: print '[ERRROR] %s' % report['errormsg'] else: if (zip_path is None) and (expected_error in report['errormsg']): print '[OK]' else: print '[ERROR]' print ' zip:', zip_path print ' msg:', report['errormsg']
def synch_repositories(repositories): if not exists(MBED_ORG_PATH): makedirs(MBED_ORG_PATH) for remote, local in repositories: print '\n=== Updating "%s" ===' % remote remote_path = join(MBED_ORG_PATH, remote) local_path = join(LIB_DIR, local) # checkout remote repository if not exists(remote_path): cmd(['hg', 'clone', MBED_OFFICIAL % remote], cwd=MBED_ORG_PATH) # copy files from local to remote for root, dirs, files in walk(local_path): for d in copy(dirs): if d.startswith('.'): dirs.remove(d) for file in files: if splitext(file)[1] == '.json': continue local_file = join(root, file) rel_path = relpath(local_file, local_path) remote_file = join(remote_path, rel_path) remote_dir = dirname(remote_file) if not exists(remote_dir): makedirs(remote_dir) copyfile(local_file, remote_file) # remove remote files that do not exist in local for root, dirs, files in walk(remote_path): for d in copy(dirs): if d.startswith('.'): dirs.remove(d) for file in files: if splitext(file)[1] == '.lib': continue remote_file = join(root, file) rel_path = relpath(remote_file, remote_path) local_file = join(local_path, rel_path) if not exists(local_file): remove(remote_file) print "remove: %s" % remote_file # Actual Mercurial synch cmd(['hg', 'addremove'], cwd=remote_path) cmd(['hg', 'status'], verbose=True, cwd=remote_path) commit = raw_input("Do you want to commit and push? Y/N: ") if commit == 'Y': cmd(['hg', 'commit', '-u', MBED_ORG_USER], verbose=True, cwd=remote_path) cmd(['hg', 'push'], verbose=True, cwd=remote_path)
def test_export(toolchain, target, expected_error=None): if toolchain is None and target is None: base_dir = join(TEMP, "zip") else: base_dir = join(TEMP, toolchain, target) temp_dir = join(base_dir, "temp") mkdir(temp_dir) zip_path, report = export(USER_PRJ, USR_PRJ_NAME, toolchain, target, base_dir, temp_dir, False, fake_build_url_resolver) if report['success']: export_name = join(EXPORT_DIR, "export_%s_%s.zip" % (toolchain, target)) cmd(["mv", zip_path, export_name]) print "[OK]" else: if expected_error is None: print '[ERRROR] %s' % report['errormsg'] else: if (zip_path is None) and (expected_error in report['errormsg']): print '[OK]' else: print '[ERROR]' print ' zip:', zip_path print ' msg:', report['errormsg']
def publish(self): # The maintainer has to evaluate the changes first and explicitly accept them cmd(['hg', 'addremove'], cwd=self.path) stdout, _, _ = run_cmd(['hg', 'status'], wd=self.path) if stdout == '': print "No changes" return print stdout commit = raw_input("Do you want to commit and push? Y/N: ") if commit == 'Y': cmd(['hg', 'commit', '-u', MBED_ORG_USER], cwd=self.path) cmd(['hg', 'push'], cwd=self.path)
def __init__(self, name): self.name = name self.path = join(MBED_ORG_PATH, name) if not exists(self.path): # Checkout code if not exists(MBED_ORG_PATH): makedirs(MBED_ORG_PATH) cmd(['hg', 'clone', MbedOfficialRepository.URL % name], cwd=MBED_ORG_PATH) else: # Update cmd(['hg', 'pull'], cwd=self.path) cmd(['hg', 'update'], cwd=self.path)
def publish(self): # The maintainer has to evaluate the changes first and explicitly accept them cmd(['hg', 'addremove'], cwd=self.path) stdout, _, _ = run_cmd(['hg', 'status'], wd=self.path) if stdout == '': print "No changes" return False print stdout if quiet: commit = 'Y' else: commit = raw_input( push_remote and "Do you want to commit and push? Y/N: " or "Do you want to commit? Y/N: ") if commit == 'Y': args = ['hg', 'commit', '-u', MBED_ORG_USER] if commit_msg: args = args + ['-m', commit_msg] cmd(args, cwd=self.path) if push_remote: cmd(['hg', 'push'], cwd=self.path) return True