예제 #1
0
def test_slot_ops():
    # Run slot operations tests
    print 'Running slot operation tests.'
    from mx.DateTime.mxDateTime import testslotops
    print

    # Try importing a subpackage
    print 'Importing subpackage Feasts.'
    print
    from mx.DateTime import Feasts
    try:
        Feasts._test()
    except SystemError:
        print '-'*72
        print 'WARNING:'
        print
        print 'Subpackges ISO and ARPA will not work on your platform because'
        print 'mxDateTime found no working API to query the timezone'
        print 'for a given date/time. Please run "python testticks.py" and send'
        print 'the output to the author at [email protected].'
        print
        print '-'*72
    print

    # Run parser tests
    print 'Importing subpackage Parser.'
    print
    from mx.DateTime import Parser
    Parser._test()

    print
    print 'Works.'
예제 #2
0
 def AddBuildInstance(self, build, dbfile_load_status, build_instance_id):
     if self.build_ids.has_key(build.name) == 0:
         self.AddBuild(build.name)
     if dbfile_load_status == -1:
         query = "INSERT INTO build_instance VALUES (NULL, %d, '%s', '%s', NULL, '%s', NOW(), NULL);" % (
             self.build_ids[build.name],
             str(Parser.DateTimeFromString(build.start_time)),
             str(Parser.DateTimeFromString(build.end_time)), build.raw_file)
         self.curs.execute(query)
         self.build_instance_ids[build.name] = self.curs.insert_id()
     else:
         query = "UPDATE build_instance SET test_insert_time=NOW() where build_instance_id=%d;" % (
             build_instance_id)
         self.curs.execute(query)
         self.build_instance_ids[build.name] = build_instance_id
예제 #3
0
    def __absolute_time(self, time_str):
        if time_str[0] == "+":
            # Relative time
            time = round_datetime(now() + ISO.ParseTime(time_str[1:]))
        else:
            time = Parser.ParseDateTime(time_str)

        return time
예제 #4
0
def guess_datetime(datetime_string):
    """
    Try to guess the datetime contained in a string of unknow format.
    @param datetime_string: the datetime representation.
    @type datetime_string: string
    @return: the guessed time.
    @rtype: L{time.struct_time}
    @raises ValueError: in case it's not possible to guess the time.
    """
    if CFG_HAS_EGENIX_DATETIME:
        try:
            return Parser.DateTimeFromString(datetime_string).timetuple()
        except ValueError:
            pass
    else:
        for format in (None, '%x %X', '%X %x', '%Y-%M-%dT%h:%m:%sZ'):
            try:
                return time.strptime(datetime_string, format)
            except ValueError:
                pass
    raise ValueError("It is not possible to guess the datetime format of %s" % datetime_string)
예제 #5
0
assert oops == 0
print '...Works.'
print

# Try importing a subpackage
print 'Importing subpackage Feasts.'
print
from mx.DateTime import Feasts
try:
    Feasts._test()
except SystemError:
    print '-'*72
    print 'WARNING:'
    print
    print 'Subpackges ISO and ARPA will not work on your platform because'
    print 'mxDateTime found no working API to query the timezone'
    print 'for a given date/time. Please run "python testticks.py" and send'
    print 'the output to the author at [email protected].'
    print
    print '-'*72
print

# Run parser tests
print 'Importing subpackage Parser.'
print
from mx.DateTime import Parser
Parser._test()

print
print 'Works.'
예제 #6
0
파일: test.py 프로젝트: zjpjohn/OpenERP
print 'Running slot operation tests.'
from mx.DateTime.mxDateTime import testslotops
print

# Try importing a subpackage
print 'Importing subpackage Feasts.'
print
from mx.DateTime import Feasts
try:
    Feasts._test()
except SystemError:
    print '-' * 72
    print 'WARNING:'
    print
    print 'Subpackges ISO and ARPA will not work on your platform because'
    print 'mxDateTime found no working API to query the timezone'
    print 'for a given date/time. Please run "python testticks.py" and send'
    print 'the output to the author at [email protected].'
    print
    print '-' * 72
print

# Run parser tests
print 'Importing subpackage Parser.'
print
from mx.DateTime import Parser
Parser._test()

print
print 'Works.'