def ensure_proplib_worldfile(path_worldfile_or_run): if not os.path.isdir(path_worldfile_or_run): path_run = os.path.dirname(path_worldfile_or_run) else: path_run = path_worldfile_or_run if not isrundir(path_worldfile_or_run): err("ensure_proplib_worldfile can only operate within a run directory") path_proplib = path_worldfile(path_run) if not os.path.exists(path_proplib): path_legacy = path_worldfile(path_run, legacy=True) if not os.path.exists(path_legacy): err("Cannot locate proplib or legacy worldfile in rundir " + path_run) exitval, stdout = get_cmd_stdout( ['wfutil.py', 'conv', '-l', path_legacy]) if exitval != 0: err("Cannot convert worldfile in rundir " + path_run) __tofile('/tmp/converted.wf', stdout) if not os.path.exists(path_schema()): err("Cannot find schema. Expected at '%s'" % path_schema()) __tofile(path_proplib, proputil('-w', 'apply', path_schema(), '/tmp/converted.wf')) shutil.copy(path_schema(), path_run) return path_proplib
def ensure_proplib_worldfile( path_worldfile_or_run ): if not os.path.isdir( path_worldfile_or_run ): path_run = os.path.dirname( path_worldfile_or_run ) else: path_run = path_worldfile_or_run if not isrundir( path_worldfile_or_run ): err( "ensure_proplib_worldfile can only operate within a run directory" ) path_proplib = path_worldfile(path_run) if not os.path.exists( path_proplib ): path_legacy = path_worldfile( path_run, legacy = True ) if not os.path.exists( path_legacy ): err( "Cannot locate proplib or legacy worldfile in rundir " + path_run ) exitval, stdout = get_cmd_stdout( ['wfutil.py', 'conv', '-l', path_legacy] ) if exitval != 0: err( "Cannot convert worldfile in rundir " + path_run ) __tofile( '/tmp/converted.wf', stdout ) if not os.path.exists( path_schema() ): err( "Cannot find schema. Expected at '%s'" % path_schema() ) __tofile( path_proplib, proputil('-w', 'apply', path_schema(), '/tmp/converted.wf') ) shutil.copy( path_schema(), path_run ) return path_proplib
def proputil(*args): proputil = pw_env('proputil') cmd = [proputil] + list(args) exitval, stdout = get_cmd_stdout(cmd) if exitval != 0: err("Failed executing '%s'. exit=%s" % (cmd, exitval)) return stdout.strip()
def proputil( *args ): proputil = pw_env( 'proputil' ) cmd = [proputil] + list(args) exitval, stdout = get_cmd_stdout( cmd ) if exitval != 0: err( "Failed executing '%s'. exit=%s" % (cmd,exitval) ) return stdout.strip()