Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Mar 28th, 2020 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import json
  2. import requests
  3. from matplotlib import pyplot as plt
  4. import datetime
  5. import struct
  6. import ctypes
  7. import os
  8.  
  9. api_url = 'https://covid19.rthand.com/api/data'
  10.  
  11. response = requests.get(api_url)
  12.  
  13. print('sup')
  14.  
  15. # print(response.status_code)
  16.  
  17. raw_data = response._content
  18.  
  19. json_data = json.loads(raw_data)
  20.  
  21. # print(type(json_data))
  22.  
  23. indexes = []
  24. positive_list = []
  25. dead_list = []
  26. daily_positive_list = []
  27. hospitalized_list = []
  28. i = 1
  29. for x, d in enumerate(json_data):
  30.     # print(d['positiveTestsToDate'])
  31.     print(d)
  32.     if d['positiveTestsToDate'] == None:
  33.         continue
  34.     if x == len(json_data) - 1 and d['positiveTestsToDate'] == 0:
  35.         print('last one!! and breaking')
  36.         break
  37.     indexes.append(i)
  38.     i = i + 1
  39.     positive_list.append(d['positiveTestsToDate'])
  40.     daily_positive_list.append(d['positiveTests'])
  41.     state_per_treatment = d['statePerTreatment']
  42.  
  43.     if state_per_treatment['deceasedToDate'] is not None:
  44.         dead_list.append(state_per_treatment['deceasedToDate'])
  45.     else:
  46.         dead_list.append(0)
  47.  
  48.     if state_per_treatment['deceasedToDate'] is not None:
  49.         hospitalized_list.append(state_per_treatment['inHospital'])
  50.     else:
  51.         hospitalized_list.append(0)
  52.  
  53.  
  54. plt.figure(figsize=(21, 9))
  55. plt.plot(indexes, positive_list, c='orange')
  56. plt.plot(indexes, dead_list, c='r')
  57. plt.plot(indexes, hospitalized_list, c='violet')
  58. # print(daily_positive_list)
  59. plt.bar(indexes, daily_positive_list)
  60.  
  61.  
  62. tfs = 8
  63.  
  64. for i, v in enumerate(daily_positive_list):
  65.     plt.text(i + 1, v + 2, str(v), horizontalalignment='center', c='blue', fontsize=tfs)
  66.    
  67. for i, v in enumerate(positive_list):
  68.     plt.text(i + 1, v + 10, str(v), horizontalalignment='center', c='orange', fontsize=tfs)
  69.    
  70. for i, v in enumerate(hospitalized_list):
  71.     if v == 0: continue
  72.     plt.text(i + 1, v + 10, str(v), horizontalalignment='center', c='violet', fontsize=tfs)
  73.  
  74. plt.legend(['Skupaj pozitivni', 'Skupaj mrtvi', 'Hospitalizirani', 'Dnevno okuženi'])
  75. plt.xticks(range(1, len(positive_list) + 1))
  76. plt.yticks(range(0, max(positive_list), 50))
  77. plt.ylabel('Št. ljudi')
  78. plt.xlabel('Dnevi od začetka')
  79.  
  80. plt.grid()
  81.  
  82.  
  83. dtobj = datetime.date.today()
  84. plt.title('{0}.{1}.{2}'.format(dtobj.day, dtobj.month, dtobj.year))
  85. fname = 'coronabg-{0}.png'.format(str(dtobj))
  86.  
  87. dirpath = os.getcwd()
  88. print(dirpath)
  89. img_path = '{0}\\img'.format(dirpath)
  90.  
  91. full_path = '{0}\\{1}'.format(img_path, fname)
  92.  
  93. if not os.path.exists(img_path):
  94.     os.makedirs(img_path)
  95.  
  96. plt.savefig(full_path, dpi=600)
  97. # plt.show()
  98.  
  99.  
  100. PATH = full_path
  101. SPI_SETDESKWALLPAPER = 20
  102.  
  103. ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, PATH, 3)
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