Пример #1
0
def match(file_name):
    for i in range(env_num + 1, total_num + 1):
        j = 22000 + i
        url = f"http://127.0.0.1:{j}"
        web3 = Web3(Web3.HTTPProvider(url))
        print(f"Connected to port {j}")
        print(web3.isConnected())
        print(web3.eth.accounts[0])
        user_acct = web3.eth.accounts[0]
        print("User Account: ")
        print(user_acct)

        with open(file_name) as json_file:
            obj_file = json.load(json_file)
            obj = obj_file['objects']
            # 改成直接從區塊鏈上抓
            _acct = user_acct
            _obj = obj[i - 4]['obj']
            _attr = obj[i - 4]['attr']
            _wishlist = obj[i - 4]['wishlist']
            # print("attr: ", _attr)
            # print("wishlist: ", _wishlist)
            register.get_url(url)
            register.run(_acct, _obj, _attr, _wishlist)
            time.sleep(1)
Пример #2
0
 def test_run(self):
     sku = "A12T-4GH7-QPL9-3N4M;65P1-UDGM-XH2M-LQW2"
     result = register.run(sku)
     self.assertEqual(True, result)
     sku = "A12T-4GH7-QPL9-3N4M;65P1-UDGM-XH2M"
     result = register.run(sku)
     self.assertEqual(False, result)
     sku = ""
     result = register.run(sku)
     self.assertEqual(False, result)
Пример #3
0
def addObj():
    if 'acct' in request.args:
        acct = request.args['acct']
        print("acct", acct)
    if 'obj' in request.args:
        obj = request.args['obj']
        print('obj', obj)
    if 'attr' in request.args:
        attr = request.args['attr']
        print('attr', attr)
    if 'wishlist' in request.args:
        wishlist = request.args['wishlist']
        print('wishlist', wishlist)

    results = jsonify(acct=acct, obj=obj, attr=attr, wishlist=wishlist)

    register.run(acct, obj, attr, wishlist)
    return results
Пример #4
0
def no_match(file_name):
    # 與不同節點建立連線,抓取每個節點的帳號
    for i in range(env_num + 1, total_num + 1):
        j = 22000 + i
        url = f"http://127.0.0.1:{j}"
        web3 = Web3(Web3.HTTPProvider(url))
        print(f"Connected to port {j}")
        print(web3.isConnected())
        print(web3.eth.accounts[0])
        user_acct = web3.eth.accounts[0]
        print("User Account: ")
        print(user_acct)

        with open(file_name) as json_file:
            obj_file = json.load(json_file)
            obj = obj_file['objects']
            # 改成直接從區塊鏈上抓
            _acct = user_acct
            _obj = obj[i - 4]['obj']
            _attr = obj[i - 4]['attr']
            _wishlist = obj[i - 4]['wishlist']
            # print("attr: ", _attr)
            # print("wishlist: ", _wishlist)
            register.get_url(url)
            register.run(_acct, _obj, _attr, _wishlist)
            time.sleep(1)

            for k in range(7):
                no = str(int(_attr[1:]) + 1)
                _obj = no
                _attr = 'n' + no
                print("no: ", no)
                print(type(no))
                print("_obj:", _obj)
                print("_attr:", _attr)
                print("wishlist: ", _wishlist)
                print(type(_wishlist))

                register.get_url(url)
                register.run(_acct, _obj, _attr, _wishlist)
                time.sleep(1)
Пример #5
0
                for i in l:
                    log("Title: %s"%article_titles[i])
                    text = get_article_body(boardname,article_ids[i],opener)
                    for user,boards,email_enable,push,device,token in receivers:
                        if boardname in boards:
                            if email_enable:
                                send_gmail(user,article_titles[i],text,boardname)
                            if push:
                                log("Push sent : %s"%user)
                                if device =='android':
                                    and_pusher.notify(token,article_titles[i],text,boardname,article_ids[i])
                                elif device == 'ios':
                                    ios_pusher.notify(token,"[%s]%s"%(boardname,article_titles[i]),boardname,article_ids[i])
    except Exception,e:
        log_error( "Exception Occured : %s"%e)

def main():
    try: 
        pid = os.fork()
        if pid > 0: 
            sys.exit(0)
    except OSError,e:
        log_error("fork failed")
        sys.exit(1)
    
    setproctitle("aracrawler")
    os.system('twistd -r epoll web --logfile=%s --class=pyapns.server.APNSServer --port=7077'%(path.join(LOG_DIRECTORY,'twistd.log')))
    crawl_wrap()
    register.run()

Пример #6
0
import faces as detect  # faces.py file is imported here
import faces_train as ft  # face.train.py file is imported here
import register as reg  # register.py  file is imported here

# add user
if_usr_added = False  # flag defined to add user
while True:
    cmd = input("Do you want to register user, yes/no :")

    if cmd.lower() == 'yes':
        reg.run()
        if_usr_added = True
    elif cmd.lower() == 'no':
        break
    else:
        print("enter yes/no only.")

# train model if new users added >>> training phase
while if_usr_added:
    cmd = input("Do you want to train model, yes/no :")

    if cmd.lower() == 'yes':
        ft.run()
        break
    elif cmd.lower() == 'no':
        break
    else:
        print("enter yes/no only.")

# detect faces >>>> final phase-- face detection
detect.run()