def get_external_resources(typename): #Reads the appropriate file (typename.list) and #returns a dict of name:uris beginning with subtypename f = os.path.join(get_data_dir(),"%s.list" % typename) data = {} if os.path.exists(f): config = ConfigParser.ConfigParser() config.read(f) #Default files first if is_online(): for k,v in config.items('DEFAULT'): data[k] = v #Machine dependent items section = Utils.get_user_string() if config.has_section(section): for k,v in config.items(section): data[k] = v return data
def get_UID(self): return Utils.get_user_string()
ok("Test program installed doesnt find foobar", Utils.program_installed('foobar') == False) fileuri = Utils.new_tempfile("bla").get_local_uri() ok("New tempfile: %s" % fileuri, os.path.isfile(fileuri)) tmpdiruri = Utils.new_tempdir() ok("New tempdir: %s" % tmpdiruri, os.path.isdir(tmpdiruri)) ok("Unique list keep order", Utils.unique_list([1,1,2,2,3,3,5,5,4,4]) == [1,2,3,5,4]) s = Utils.random_string() ok("Random string: %s" % s, len(s) > 0 and type(s) == str) s = Utils.md5_string('Foo') ok("md5 string: %s" % s, len(s) > 0 and type(s) == str) s = Utils.uuid_string() ok("uuid string: %s" % s, len(s) > 0 and type(s) == str) s = Utils.get_user_string() ok("user string: %s" % s, len(s) > 0 and type(s) == str) #test command line processing ok("Cmd executed", len(Utils.exec_command_and_return_result("ls",".")) > 0) ok("Cmd with wrong args", Utils.exec_command_and_return_result("ls","does-not-exist") == None) ok("Cmd that doesnt exist", Utils.exec_command_and_return_result("cmd-does-not-exist",".") == None) ts = 0 dt = Utils.datetime_from_timestamp(ts) ok("Datetime to unix timestamp", Utils.datetime_get_timestamp(dt) == ts) ok("Unix timestamp to datetime", Utils.datetime_from_timestamp(ts) == dt) m = Memstats.Memstats() VmSize,VmRSS,VmStack = m.calculate() ok("Memstats: size:%s rss:%s stack:%s" % (VmSize,VmRSS,VmStack), VmSize > 0 and VmRSS > 0 and VmStack > 0)