Ejemplo n.º 1
0
def debug(item=None, time=datetime.now(), urgency='sub'):
    if urgency not in urgencies:
        raise Exception('Not a valid logging urgency')

    if type(item) == FunctionType:
        def wrapper(*args):
            resp = item(*args)
            debug_print(resp, time, urgency)
            return resp
        return wrapper
    elif type(item) == StringType:
        debug_print(item, time, urgency)
Ejemplo n.º 2
0
def debug_print(message, time, urgency):
    """
    debug_print("My foo!", datetime.now(), 'out') # results in
    " -> [15:21.33] My foo!"
    """
    timeformat = "%H:%M.%S"   
    out = " %s [%s] %s" % (urgencies[urgency], time.strformat(timeformat), message)

    log = cache.get_cache()
    log.append((datetime.now(), out))

    # Don't let log go past LOGSIZE
    if (len(log) is settings.LOGSIZE):
        log.pop(0)

    self.c.log = log
Ejemplo n.º 3
0
# This is how you would show the current time in python. #

import time
from time import datetime


now = datetime.now()
print(now)
Ejemplo n.º 4
0
    for subitem in item['Transactions']:
        sql_ts = subitem['SalesDate']
        cursor.execute(get_token_valid.format(str(sql_ts)[:-7])
        token_item = cursor.fetchone()
        while token_item:
            if 'Event : Token only payload:' in token_item['Message']:
                tag07data = token_item['Message'].split('|')
                subitem['Token'] = re.search(r'(07){1}([0-9]*)', tag07data[-2]).group(2)

            token_item = cursor.fetchone()
        
        subitem['ProviderID'] = card_to_ID[subitem['CardType']]

# insert token and ProviderID into Transaction and update record
for item in batch_invalid: 
    for subitem in item['Transactions']:
        pass # cursor.execute(update_token_valid.format(**subitem))

# reset each batch for auto settlement
if batch_invalid:
    for item in batch_invalid:
        cursor.execute(update_batch.format(item['ID']))

conn.close()

# Write all data involved in batch investigation to new file with timestamp
now = datetime.now()
new_file = now.strftime('%Y%m%d-%H%M%S') + '-Settle_Investigate.txt'
with open(new_file, 'w') as f:
    f.write(str(batch_invalid))
Ejemplo n.º 5
0
#!/software/bin/python2.7

#note: try using /software/bin/python2.7  for running your python code!

import sys
import os
import re
from time import datetime


stime = datetime.now()
mapable = open("/nfs/th_group/hk3/MAPPABLE_DATA_HG19/UCSC_MAPABLE/wgEncodeCrgMapabilityAlign36mer_chr1.wig", "r")
header_line = mapable.readline()
first_line  = mapable.readline()
firt_chro, first_start, first_end, first_score = first_line.split()
second_line  = mapable.readline()
second_chro, second_start, second_end, second_chro =second_line.split()
first_start =  int(first_end)
second_start = int(second_start)
if not first_end == second_start:
    print first_end, second_start

    counter = 0

while not first_end == second_start:
    counter = counter+1
    print counter
    first_line = second_line
    second_line = mapable.readline()
    firt_chro, first_start, first_end, first_score = first_line.split()
    f = mapable.readline()
Ejemplo n.º 6
0
# -*- coding: utf-8 -*-
"""
Created on Fri Jun  5 13:55:43 2020

@author: Usuario
"""

from random import randint
from time import datetime
tiempo_inicial = datetime.now()
lista = [20, 10, 5]

for i in range(0, 10):
    lista.append(randint(0, 10000000))

print(lista)

temp = 0
"""
for J in range(l, len(lista)):
    for i in range (0, len(lista)-j):
        if lista [i]>lsita[i+l]:
            temp=lista[i]
            lista[i]=lista[i+l]
            lista[i+l]=temp 
"""
tiempo_final = datetime.now()
d = str(tiempo_final - timepo_inicial)
print("tiempo de ejecucion: " + d)