示例#1
0
 def _get_note_mtime(self, uid):
     try:
         timestr = self.remoteTomboy.GetNoteChangeDate(uid)
         mtime = Utils.datetime_from_timestamp(int(timestr))
     except:
         log.warn("Error parsing tomboy note modification time")
         mtime = None
     return mtime
示例#2
0
 def _get_note_mtime(self, uid):
     try:
         timestr = self.remoteTomboy.GetNoteChangeDate(uid)
         mtime = Utils.datetime_from_timestamp(int(timestr))
     except:
         log.warn("Error parsing tomboy note modification time")
         mtime = None
     return mtime
示例#3
0
 def _get_proxyfile(self, key):
     """
     @param key: Key for which C{ProxyFile} should be returned.
     @type key: C{boto.s3.key.Key}
     @returns: C{ProxyFile} stored under supplied parameter C{key}.
     """
     httpurl = key.generate_url(AmazonS3TwoWay.AWS_URL_EXPIRE_SECONDS)
     # BUG This will fail with "Access denied"
     # (see http://bugzilla.gnome.org/show_bug.cgi?id=545000)
     return File.ProxyFile(
         httpurl, key.name,
         Utils.datetime_from_timestamp(long(key.get_metadata("mtime"))),
         long(key.get_metadata("size")))
示例#4
0
 def _get_proxyfile(self, key):
     """
     @param key: Key for which C{ProxyFile} should be returned.
     @type key: C{boto.s3.key.Key}
     @returns: C{ProxyFile} stored under supplied parameter C{key}.
     """
     httpurl = key.generate_url(AmazonS3TwoWay.AWS_URL_EXPIRE_SECONDS)
     # BUG This will fail with "Access denied"
     # (see http://bugzilla.gnome.org/show_bug.cgi?id=545000)
     return File.ProxyFile(
         httpurl,
         key.name,
         Utils.datetime_from_timestamp(long(key.get_metadata("mtime"))),
         long(key.get_metadata("size")))
示例#5
0
#common sets up the conduit environment
from common import *

import os
import conduit
import conduit.datatypes.File as File
import conduit.utils as Utils

#check construction arg type checking
try:
    i = Utils.datetime_from_timestamp("Foo")
    ok("datetime_from_timestamp only accepts numbers", False)
except:
    ok("datetime_from_timestamp only accepts numbers", True)


try:
    i = Utils.datetime_from_timestamp("Foo")
    ok("datetime_get_timestamp only accepts datetimes", False)
except:
    ok("datetime_get_timestamp only accepts datetimes", True)

#make another local file
local = Utils.new_tempfile(Utils.random_string())

#get timestamp and mtimes
dt = local.get_mtime()
ts = Utils.datetime_get_timestamp(dt)

#now get timestamp using os.stat
pts = os.stat(local.get_local_uri()).st_mtime
示例#6
0
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")
cmdok,output = conv.convert("/tmp","/dev/null",callback=None,save_output=True)

ok("Command executed ok", cmdok == True and len(output) > 0)

ok("Simple xml tag extractor",