Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Apr 7th, 2020 300 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. import time
  3. import json
  4. import numpy as np
  5. import pandas as pd
  6. import requests
  7.  
  8.  
  9. import highest_pos as conn
  10.  
  11. DB_PATH = 'DatabaseServer.mdb'
  12. KOMAX_ID = 'AAAAA'
  13. PRODUCTION = False
  14. if PRODUCTION:
  15.     URL = 'https://komaxsite.herokuapp.com/api/v1/komax/'
  16. else:
  17.     URL = 'http://localhost:8000/api/v1/komax/'
  18. KOMAX_NUMBER = 1
  19.  
  20. # db_connection = conn.Position(DB_PATH)
  21. """
  22. komax_wb = load_workbook('New_excel.xlsx')
  23. ws = komax_wb.active
  24. komax_df = pd.DataFrame(ws.values)
  25. komax_df.columns = komax_df.loc[0, :]
  26. komax_df = komax_df.iloc[2:, 2:24]
  27. komax_df.index = pd.Index(range(komax_df.shape[0]))
  28. komax_df = komax_df[komax_df['komax'] == str(KOMAX_NUMBER)]
  29. """
  30.  
  31.  
  32. #print(komax_df.columns)
  33.  
  34.  
  35. def to_normal_int(number):
  36.     type_number = type(number)
  37.     if type_number is np.int64 or type_number is np.int32 or type_number is np.int16 or type_number is np.int8 or type_number is np.int_:
  38.         return int(number)
  39.  
  40. def to_normal(value):
  41.     type_value = type(value)
  42.     if type_value is str or type_value is int or type_value is float or type_value is bool:
  43.         return value
  44.     elif type_value is np.bool_:
  45.         return bool(value)
  46.     else:
  47.         return to_normal_int(value)
  48.  
  49. #print(sum(komax_df.loc[148:, :][komax_df['harness'] == '43118-3724544-45']['time']))
  50.  
  51. # d = {key: [to_normal_int(value)] for key, value in d.items()}
  52.  
  53. #print(komax_df[komax_df.isin(d).all(), :])
  54.  
  55. #komax_df[[komax_df[] == d[key]] and ]
  56. # komax_df = None
  57.  
  58. client = requests.session()
  59. # komax_df = pd.read_excel('komax_df_{}.xlsx'.format(KOMAX_NUMBER))
  60. komax_df = None
  61. idx_to_send = 0
  62.  
  63. # start connection
  64. client.get(URL, params={'komax-number': KOMAX_NUMBER})
  65. CSRF_TOKEN = client.cookies['csrftoken']
  66.  
  67. while True:
  68.     status = 1
  69.     if komax_df is not None and idx_to_send is not None:
  70.         to_send = komax_df.iloc[idx_to_send, :].to_dict()
  71.         for key, value in to_send.items():
  72.             to_send[key] = to_normal(value)
  73.     else:
  74.         to_send = 1
  75.  
  76.     if type(to_send) is dict:
  77.         params={
  78.             'status': status,
  79.             'position': json.dumps(to_send),
  80.             'csrfmiddlewaretoken': CSRF_TOKEN,
  81.         }
  82.     else:
  83.         params={
  84.             'status': status,
  85.             'position': 1,
  86.             'csrfmiddlewaretoken': CSRF_TOKEN,
  87.         }
  88.     """
  89.    headers = {
  90.        'csrfmiddlewaretoken': csrftoken,
  91.        'HTTP_REFERER': URL,
  92.        'Referer': URL,
  93.        ''
  94.        '_csrftoken': csrftoken
  95.    }
  96.    """
  97.  
  98.  
  99.     req_info_position = client.post(URL, data=params)
  100.  
  101.  
  102.     data = req_info_position.json()
  103.  
  104.     if len(data):
  105.         status = data.get('status', None)
  106.         text = data.get('text', None)
  107.         task = data.get('task', None)
  108.         if status is not None and status == 2:
  109.             if text is not None and text == 'Requested':
  110.                 req_task_send = client.post(URL, params={
  111.                     'status': status,
  112.                     'text': text,
  113.                     'task': komax_df.to_dict(),
  114.                     'csrfmiddlewaretoken': csrftoken,
  115.                 })
  116.  
  117.             elif task is not None:
  118.                 komax_df = pd.DataFrame(task)
  119.                 komax_df.index = pd.Index(komax_df['id'])
  120.                 # save komax_df to excel
  121.                 #komax_df.to_excel('komax_df_{}.xlsx'.format(KOMAX_NUMBER))
  122.                 #print(komax_df)
  123.  
  124.     idx_to_send += 1
  125.     if idx_to_send == komax_df.shape[0]:
  126.         idx_to_send = None
  127.     time.sleep(1)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top