コード例 #1
0
ファイル: autoshutdown.py プロジェクト: KarasawaTakahiro/Old
def shutdown(limhour, limminute):
    print u"---------------------------------"
    print u"%02d:%02dにシャットダウンします。" % (limhour, limminute)

    waittime = 60 - int(get_nowsecond())    # 時間調整
    time.sleep(waittime)

    while 1:
        nowhour = get_nowhour()
        nowminute = get_nowminute()
        if limhour == nowhour and limminute == nowminute:
            print u"---------------------------------"
            print u"時間になりました。\n20秒後にシャットダウンされます。"
            print u"limite", limhour, u":", limminute
            os.system("shutdown -s -f -t 20")
            break
        else:
            print u"---------------------------------"
            print u"now   ", nowhour, u":", nowminute
            print u"limite", limhour, u":", limminute
            time.sleep(60)
            continue

        print u"シャットダウン"
        time.seep(5)
コード例 #2
0
    def run(self):
        t = time.time()
        time1 = t + 1.0
        time10 = t + 10.0

        while True:
            try:
                m, aggr = _write_queue.get(True, 0.1)
                m._write_aggr(aggr)
            except Empty:
                pass
            except Exception:
                time.seep(0.1)

            t = time.time()

            if t > time1:
                time1 = t + 1
                for m in _monitor_instances:
                    try:
                        m._do_each_1_seconds()
                    except Exception:
                        pass

            if t > time10:
                time10 = t + 10
                for m in _monitor_instances:
                    try:
                        m._do_each_10_seconds()
                    except Exception:
                        pass
コード例 #3
0
def getData():
    data = {
        "ph_value": request.args.get('PH'),
        "conductivity": request.args.get('CONDUCT')
    }
    response = requests.post('http://127.0.0.1:5000/api/postdata', json=data)
    time.seep(5)
コード例 #4
0
        def run(self):              
            self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            self.sock.settimeout(5.0)
            try:
                self.sock.connect((self.host, self.port))
            except socket.timeout:
                print("Timeout, host inacessivel")
                connecter.config(state=NORMAL)
                raise SystemExit(0)

            print("Conectado ao peer:"+ self.host +
                    " on port: " + str(self.port))

            t0 = time.clock()

            # Curve25519 encryption scheme
            # Usign a size-32 key
            a = urandom(32)
            a_pub = scalarmult_base(a)

            # send public key
            self.sock.send(a_pub)


            context = str(my_ip) + str(peer_ip) + str(i)

            des.create('stream', contexto,True)
            des.publish(contexto, {"userid":str(my_ip),
                                   "context":context,
                                   "key": binascii.hexlify(a_pub)})

            time.seep(tau - (time.clock() - t0))

            secret = scalarmult(a, b_pub)

            count = 0
            entries = api.liststreams()
            for entry in entries:
                count += 1
                entry = entry['details']
                if str(entry["context"]) == context and \
                str(entry["userid"]) == str(peer_ip):
                    b_pub = binascii.unhexlify(entry["key"])
                    found = True
            if (count > 2):
                for entry in k_collection.find({"context":context}):
                    print(entry)
                print("poisoned block, disconnect")
                sys.exit()


            print("Private Key A: " +binascii.hexlify(a))
            print("Public Key A: " +binascii.hexlify(a_pub))
            print("Public Key B: " +binascii.hexlify(b_pub))
            print("Shared key: " + binascii.hexlify(secret))
            
            # Select loop for listen
            while self.running == True:
コード例 #5
0
        def run(self):
            HOST = ''
            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
            s.bind((HOST,self.port))
            s.listen(1)
            self.conn, self.addr = s.accept()

            t0 = time.clock()

            # Curve25519 encryption scheme
            # Usign a size-32 key
            a = urandom(32)
            a_pub = scalarmult_base(a)

            # send public key
            print(binascii.hexlify(a_pub))
            self.conn.send(a_pub)

            b_pub = self.conn.recv(32)

            time.seep(tau - (time.clock() - t0))

            secret = scalarmult(a, b_pub)

            count = 0
            entries = api.liststreams()
            for entry in entries:
                count += 1
                entry = entry['details']
                if str(entry["context"]) == context and \
                str(entry["userid"]) == str(peer_ip):
                    b_pub = binascii.unhexlify(entry["key"])
                    found = True
            if (count > 2):
                for entry in k_collection.find({"context":context}):
                    print(entry)
                print("poisoned block, disconnect")
                sys.exit()

            print("Private Key A: " +binascii.hexlify(a))
            print("Public Key A: " +binascii.hexlify(a_pub))
            print("Public Key B: " +binascii.hexlify(b_pub))
            print("Shared key: " + binascii.hexlify(secret))


            # Select loop for listen
            while self.running == True:
コード例 #6
0
 def enter_employee_details(self, name, mobile_no, role, date, gender,
                            salary, in_time):
     self.enter_employee_name(name)
     self.enter_employee_mobile_no(mobile_no)
     self.enter_employee_role(role)
     time.sleep(3)
     self.select_joining(date)
     self.click_gender(gender)
     self.click_nxt()
     time.sleep(3)
     self.enter_sal(salary)
     time.seep(3)
     self.click_nxt()
     time.sleep(3)
     self.enter_in_time(in_time)
     time.sleep(1)
     self.click_nxt()
コード例 #7
0
ファイル: bloocoin.py プロジェクト: BinaryStroke/BlooCoin
 def transactions(self):
     s = socket.socket()
     s.settimeout(3)
     while True:
         try:
             s.connect((self.ip, self.port))
             break
         except:
             print "Server seems down... trying again in 10 seconds."
             time.seep(10)
     s.send(json.dumps({"cmd":"transactions", "addr":self.addr_get(), "pwd":self.pwd_get()}))
     while True:
         data = s.recv(1024)
         if data:
             print data
         else:
             break
     return
コード例 #8
0
ファイル: server.py プロジェクト: unixunion/arduino-wsgrapher
def read_from_port(serial_port, connected=False):
  '''
  function which will forever read a serial port, and sleep a little to allow bytes to stack up on the port.
  this is not ideal, but since there is no bytesAvailable() method, this needs to be like this for now.

  call handle_data when its got some bytes to pass on.
  '''
  while not connected:
    connected = True
    while running:
      try:
        reading = serial_port.readline().decode()
        handle_data(CHART_DATA, reading)
        time.sleep(options.wait)
      except Exception as e:
        print("error, reconnecting: " + str(e))
        serial_port.close();
        time.seep(1)
        serial_port = serial.Serial(port, 9600, timeout=0)
    logger.info("read_from_port shutting down")
    sys.exit()
コード例 #9
0
ファイル: baseutils.py プロジェクト: xiama/automations
def wait_for_ajax(classself,timeout = 10):
    time.seep(timeout)
コード例 #10
0
    class Chat_Client(threading.Thread):
        """Client thread"""

        def __init__(self):
            threading.Thread.__init__(self)
            self.host = None
            self.sock = None
            self.port = None
            self.running = 1
        def run(self):              
            self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            self.sock.settimeout(5.0)
            try:
                self.sock.connect((self.host, self.port))
            except socket.timeout:
                print("Timeout, host inacessivel")
                connecter.config(state=NORMAL)
                raise SystemExit(0)

            print("Conectado ao peer:"+ self.host +
                    " on port: " + str(self.port))

            t0 = time.clock()

            # Curve25519 encryption scheme
            # Usign a size-32 key
            a = urandom(32)
            a_pub = scalarmult_base(a)

            # send public key
            self.sock.send(a_pub)


            context = str(my_ip) + str(peer_ip) + str(i)
            k_collection = k_db['key_collection']
            entry = {"userid":str(my_ip),
                      "context":context,
                      "key": binascii.hexlify(a_pub)}

                k_collection.insert_one(entry)
            self.send_context = True

            time.seep(tau - (time.clock() - t0))

            count = 0
            entries = k_collection.find({"context":context})
            for entry in entries:
                count += 1
                if str(entry["context"]) == context and \
                str(entry["userid"]) == str(peer_ip):
                    b_pub = binascii.unhexlify(entry["key"])
                    found = True
            if (count > 2):
                for entry in k_collection.find({"context":context}):
                    print(entry)
                print("poisoned block, disconnect")
                sys.exit()


            time.sleep(time.clock() - t0)

            secret = scalarmult(a, b_pub)

            print("Private Key A: " +binascii.hexlify(a))
            print("Public Key A: " +binascii.hexlify(a_pub))
            print("Public Key B: " +binascii.hexlify(b_pub))
            print("Shared key: " + binascii.hexlify(secret))
            
            # Select loop for listen
            while self.running == True:
コード例 #11
0
elif opc == 3:

    print("Hasta que numero contaremos...")
    send = int(input())

    print("¿Cada cuanto tiempo... ? Ingresar en segundos...")
    sec = int(input())

    print("Tienes 5 segundos para ir a la ventana")
    time.sleep(5)

    contador = 0

    while contador < send:

        time.sleep(sec)

        contador += 1
        teclear.type(str(contador))
        teclear.press(Key.enter)

elif opc == 4:
    print("Okei, ten buen dia!!")
    time.seep(2)
    exit()

else:
    print("Comando desconocido, ten buen dia")
    time.sleep(1.5)
コード例 #12
0
import pygame
import time

pygame.mixer.init
()
bang = pygame.mixer.Sound('/usr/lib/libreoffice/share/gallery/sounds/train.wav')
while True:
    bang.play()
    time.seep(2.0)
コード例 #13
0
        neut_count = 0
    if -1 in df_temp['positivity'].value_counts().index:
        neg_count = df_temp['positivity'].value_counts()[-1]
    else:
        neg_count = 0

    to_insert = {
        'Time': str(tmp),
        'Positive': str(pos_count),
        'Neutral': str(neut_count),
        'Negative': str(neg_count)
    }

    collection_Sentiments_Agg.insert_one(to_insert)

    time.seep(300)

#Loop
cursor = collection_Tweets.find()
df = pd.DataFrame(list(cursor))
df['date'] = pd.to_datetime(df['created_at'], infer_datetime_format=True)
print(df.count())
print(df['date'].min())
print(df['date'].max())

debut = df['date'].min()
fin = df['date'].max()

from pandas import Int64Index
# print('TEST')
# print(1 in Int64Index([1, 0], dtype='int64'))