Ejemplo n.º 1
0
    def __init__(self, *args):
        #Put photos into the users Pictures dir
        pdir = Utils.exec_command_and_return_result("xdg-user-dir", "PICTURES")
        if pdir:
            folder = "file://" + pdir.strip()
        else:
            folder = "file://" + Utils.new_tempdir()

        log.info("Storing pictures in %s" % folder)

        FileDataProvider.FolderTwoWay.__init__(self,
                                               folder=folder,
                                               folderGroupName="Pictures",
                                               includeHidden=False,
                                               compareIgnoreMtime=False,
                                               followSymlinks=False)

        if WPTYPE == WPGNOME:
            self._client = gconf.client_get_default()
Ejemplo n.º 2
0
    def __init__(self, *args):
        #Put photos into the users Pictures dir
        pdir = Utils.exec_command_and_return_result("xdg-user-dir", "PICTURES")
        if 1:
            folder = "file://"+pdir.strip()
        else:
            folder = "file://"+Utils.new_tempdir()

        log.info("Storing pictures in %s" % folder)

        FileDataProvider.FolderTwoWay.__init__(
                            self,
                            folder=folder,
                            folderGroupName="Pictures",
                            includeHidden=False,
                            compareIgnoreMtime=False,
                            followSymlinks=False
                            )

        self._client = gconf.client_get_default()
Ejemplo n.º 3
0
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)

# Test the shiny command line executer
conv = CommandLineConverter.CommandLineConverter()
conv.build_command("ls %s %s")