Esempio n. 1
0
def set_min_max(xdata, ydata, xtime=0, ybot=-999):
    """
    set plotting range
    Input:  xdata   ---- xdata
            ydata   ---- ydata
            xtime   ---- if it is >0, it set the plotting range from 1999 to the current in year
            ybot    ---- if it is == 0, the ymin will be 0, if the ymin computed is smaller than 0
    Output: [xmin, xmax, ymin, ymax]
    """

    xmin = min(xdata)
    xmax = max(xdata)
    xdiff = xmax - xmin
    xmin -= 0.1 * xdiff
    xmax += 0.2 * xdiff

    if xtime > 0:
        xmin = 1999
        xmax = int(float(time.strtime("%Y", time.gmtime()))) + 1

    ymin = min(ydata)
    ymax = max(ydata)
    ydiff = ymax - ymin
    ymin -= 0.1 * ydiff
    ymax += 0.2 * ydiff

    if ybot == 0:
        if ymin < 0:
            ymin = 0

    return [xmin, xmax, ymin, ymax]
Esempio n. 2
0
def record_logger(logfilepath, id):
    wrfp = open(logfilepath, 'a', buffering=1)
    # while True:
    for _ in range(10):
        record_content = str(id) + '' + time.strtime(
            "%Y %m %d %H:%M:%S") + '\n'
        print(record_content)
        wrfp.write(record_content)
        time.sleep(1)
        id += 1
        wrfp.close()
Esempio n. 3
0
 def __init__(self):
     print '\033[1;30;46m -----报告: 开始进行手机采集 --------- begin time:\033[46m' + time.strftime('\033[1;30;0m%Y-%m-%d %H:%M:%S\033[0m',time.localtime(time.time()))
     print '\033[1;30;0m *****************\033[0m'
     print ' Time: ' + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) + '\t\t报告:开始读取手机型号库'
     if Model.Phone_name:
         print ' Time:'+ time.strtime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())) +'\t\t报告:已找到手机型号库'
     else:
         print '\033[5;31;0m Error : 没有找到手机型号 \033[0m'
     while True:
         aa = Model.redis_dyjRedis.lpop(Model.redis_key_phone)
         if aa:
             PhoneJson = json.loads(aa)
             PhoneName = PhoneJson['model']
             Brand = PhoneJson['brand']
         else:
             break
Esempio n. 4
0
#!/usr/local/python/bin/python
#-*-coding:utf-8-*-
print "refer"
a = [1,2,3]
print a
print id(a)
b = a
print id(b)
a[1]=6
print a
print b
print "copy"
a = [1,2,3]
b = a[:]
a[1] =6
print a
print b
"""
refer
[1, 2, 3]
3085248492
3085248492
[1, 6, 3]
[1, 6, 3]
copy
[1, 6, 3]
[1, 2, 3]
"""
import time
a = time.strtime('%Y-%m-%d',time.localtime(time.time()))
print a
Esempio n. 5
0
import time

host = 'localhost'
port = 9090
clients = []

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((host, port))
quit = False
print('[Server Started]')

while not quit:
    try:
        data, addr = s.recvfrom(1024)
        if addr not in clients:
            clients.append(addr)

        itsatime = time.strtime('%Y-%m-%d-%H.%M.%S', time.localtime())

        print("[" + addr[0] + "]=[" + str(addr[1]) + itsatime + "] / ", end="")
        print(data.decode("utf-8"))
        for client in clients:
            if addr != client:
                s.sendto(data, client)
    except Exception as ex:
        print(ex)
        print("\n[ Server Stopped ]")
        quit = True

s.close()
Esempio n. 6
0
def cover_stamp_to_time(my_stamp, format_str='%Y-%m-%D %H:%M:%S'):
    t = time.strtime(format_str, my_stamp)
    return t
Esempio n. 7
0
clients = []

# создаем сокет
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((host, port))
quit = False
print("[ Server Started ]")
# создаем сокет
while not quit:
    try:
        # принимаем данные с клиентов: данные, адрес клиента
        data, addr = s.recvfrom(1024)

        #если клиент "новый", добавляем его в наш список
        if addr not in clients:
            clients.append(addr)
        #текущее время
        itsatime = time.strtime("%Y-%m-%d-%H.%M.%S", time.localtime())

        print("[" + addr[0] + "]=[" + str(addr[1]) + "]=[" + itsatime + "]/",
              end="")
        print(data.decode("utf-8"))
        for client in clients:
            if addr != client:
                s.sendto(data, client)
    except Exception as ex:
        print(ex)
        print("\n[ Server Stoppped ]")
        quit = True
#Не забываем закрывать сокет
s.close()
Esempio n. 8
0
def get_time():
  return time.strtime(" %Y-%m-%d_%H:%M:%S", time.gmtime())
Esempio n. 9
0
cdr2 = frame(root, bg="#5bd", relief=RIDGE)
cdr2.grid()

cdr3 = frame(root, bg="#5bd", relief=RIDGE)
cdr3.grid()

#-------diffrent string variables for displaying necessary info------

str1 = StringVar()
str1.set("Piano is awesome!")

date1 = StringVar()
time1 = StringVar()

date1.set(time.strtime("%d/%m/%Y"))
time1.set(time.strtime("%H:%M:%S"))

#--------------main label tuple -------------
Label(cdr1, text="Virtual PIANO", font=('arial',25, 'bold'), padx = 8, pady = 8, bd = 4, bg ="#5bd",
fg = "#ffbfa1", width=28, justify=CENTER).grid(row = 0 , column = 0, columnspan = 11 )

#---------defining commandlines for piano keys-------
def value_CS():
    str1.set("C#")
    sound = pygame.mixer.Sound("C:\Users\rc\SkyDrive\Documents\PIANO PROJECT\Music_Notes\C_s.wav")
    sound.play
    return

def value_DS():
    str1.set("D#")
Esempio n. 10
0
 def fn(*args, **kw):
     print 'call' + f._name_ + '()...' + 'time' + time.strtime(
         '%Y-%m-%d', time.localtime(time.time()))
     return f(*args, **kw)
def adddttofilename(fname):
    datet = str(time.strtime("%Y%m%d-%H%M%S"))
    if '%%' in fname:
        fname = fname.replace('%%', datet)
    return fname
Esempio n. 12
0
import time
for _ in range(10):
    record_content = str(id) + '' + time.strtime("%Y-%m-%d %H:%M:%S") + '\n'
    print(record_content)
    wrfp.write(record_content)
    time.sleep(1)
    id += 1
    wrfp.close()