예제 #1
0
def _iso8601_to_ts(s):
    """Parse ISO-8601 string to microsecond POSIX timestamp."""
    try:
        s = str(s)
        if s.isnumeric():
            # Valid type, no conversion required.
            return long(s)
        tm = time.strptime(s, '%Y-%m-%d %H:%M:%S')
        dt = datetime(*(tm[0:6] + (0, utc)))
        return to_utimestamp(dt)
    except (AttributeError, TypeError, ValueError):
        # Create a valid timestamp anyway.
        return to_utimestamp(datetime.now(utc))
예제 #2
0
파일: model.py 프로젝트: lkraav/trachacks
 def do_update(db):
     cursor = db.cursor()
     now = to_utimestamp(datetime.now(utc))
     cursor.execute("""
         UPDATE subscription
            SET changetime=%s,
                priority=%s
          WHERE id=%s
     """, (now, int(self.values['priority']), self.values['id']))
예제 #3
0
 def do_update(db):
     cursor = db.cursor()
     now = to_utimestamp(datetime.now(utc))
     cursor.execute(
         """
         UPDATE subscription
            SET changetime=%s,
                priority=%s
          WHERE id=%s
     """, (now, int(self.values['priority']), self.values['id']))
예제 #4
0
파일: model.py 프로젝트: lkraav/trachacks
 def do_insert(db):
     cursor = db.cursor()
     priority = len(cls.find_by_sid_and_distributor(env,
         subscription['sid'], subscription['authenticated'],
         subscription['distributor'], db)) + 1
     now = to_utimestamp(datetime.now(utc))
     cursor.execute("""
         INSERT INTO subscription
                (time,changetime,sid,authenticated,
                 distributor,format,priority,adverb,class)
         VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s)
     """, (now, now, subscription['sid'], subscription['authenticated'],
           subscription['distributor'], subscription['format'],
           int(priority), subscription['adverb'], subscription['class'])
     )
예제 #5
0
 def do_insert(db):
     cursor = db.cursor()
     priority = len(
         cls.find_by_sid_and_distributor(
             env, subscription['sid'], subscription['authenticated'],
             subscription['distributor'], db)) + 1
     now = to_utimestamp(datetime.now(utc))
     cursor.execute(
         """
         INSERT INTO subscription
                (time,changetime,sid,authenticated,
                 distributor,format,priority,adverb,class)
         VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s)
     """,
         (now, now, subscription['sid'], subscription['authenticated'],
          subscription['distributor'], subscription['format'],
          int(priority), subscription['adverb'], subscription['class']))