def _clone(ctx): red = ctx.red cyan = ctx.cyan reset = ctx.reset remote = ctx.get_option(0) if not remote: print(f'''USAGE: mold root --clone (git-uri) [--force] run 'mold root --clone help' for more info''') return ctx.FAIL if fs.exists(ctx.MOLD_ROOT): if not ctx.check_flag_set('--force'): print( f'{red}WARNING:{reset} {ctx.MOLD_ROOT} allready exists do you want to remove it?' ) abort = 'y' != input( f'{cyan}Do you want to contiune the installation? y/n:{reset} ' ).strip() if (abort): print('Ok, mold --clone aborted.') return ctx.OK fs.rimraf(ctx.MOLD_ROOT) git.clone(ctx, remote) result = check(ctx) if result != ctx.NEXT_COMMAND: return ctx.FAIL ctx.link_conf() return ctx.OK
def _create_mold_root(ctx): try: if fs.exists(ctx.MOLD_ROOT): fs.rimraf(ctx.MOLD_ROOT) fs.copy_dir(BUILD_DIR + '/mold_root', ctx.MOLD_ROOT) return True except: return False
def test_create_and_destory_dir(self): dirpath = TEMP_DIR + '/test_mkdir' filepath = TEMP_DIR + '/test_mkdir/cool' fs.mkdir(dirpath) fs.mkfile(filepath) assert fs.exists(dirpath) assert fs.is_dir(dirpath) fs.rimraf(dirpath) assert not fs.exists(dirpath)
def _drop(ctx): if not ctx.check_has_options(): return _usage(ctx, '(name)') filename = ctx.get_option(0) filepath = ctx.get_command_dir() + '/' + filename if fs.exists(filepath): if ctx.command == 'fold': fs.rimraf(filepath) else: fs.rm(filepath) print(f'REMOVED {filename} FROM $MOLD_ROOT/{ctx.command}') return print(f'ERROR: no "{filename}" {ctx.command} file found')
def teardown_method(self, test_method): fs.rimraf(TEMP_DIR)