Guest User

Untitled

a guest
Dec 15th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. from datetime import datetime, timedelta
  2. import requests
  3. import os
  4. print(1)
  5.  
  6. #Login API to get the token
  7. reqLogin = requests.post('http://139.162.29.201:3001/auth/sign_in', json = {'email': 'aa', 'password': 'aa'})
  8. reqLogin = reqLogin.json()
  9. print(2)
  10. #Get all the clients
  11. reqClient = requests.request('GET', 'http://139.162.29.201:3001/clients', headers = {'Authorization': 'JWT '+ reqLogin['token']})
  12. reqClient = reqClient.json()
  13. print(3)
  14. #Initialize time
  15. #time = (datetime.now() + timedelta(hours = 5, minutes = 30)).strftime('%H:%M:%S')
  16. time = "05:59:50"
  17. timeInSecondsList = time.split(":")
  18. time = timedelta(hours = int(timeInSecondsList[0]), minutes = int(timeInSecondsList[1]))
  19. print(4)
  20. #Initialize date
  21. dateTime = (datetime.now() + timedelta(hours = 5, minutes = 30)).strftime('%Y-%m-%d')
  22. dateTimeYesterday = (datetime.now() + timedelta(days = -1, hours = 5, minutes = 30)).strftime('%Y-%m-%d')
  23. print(5)
  24. for eachClient in reqClient:
  25. #Get the shift timing against the client
  26. reqShiftTiming = requests.post('http://139.162.29.201:3001/getShiftTiming', headers = {'Authorization': 'JWT '+reqLogin['token']}, json = {'clientId': eachClient['clientId']})
  27. reqShiftTiming = reqShiftTiming.json()
  28. print(6)
  29. shiftAList = reqShiftTiming[0]['shiftA'].split(":")
  30. shiftBList = reqShiftTiming[0]['shiftB'].split(":")
  31. shiftCList = reqShiftTiming[0]['shiftC'].split(":")
  32. print(7)
  33. if time == timedelta(hours = int(shiftBList[0]), minutes = int(shiftBList[1]) - 1):
  34. print(8)
  35. file = 'python /quad/finalMachineEfficiency.py '+ eachClient['clientId'] + ' ' + timeInSecondsList[0] + ':' + timeInSecondsList[1] + ' ' + dateTime
  36. os.system(file)
  37. print(os.system(file))
  38. if time == timedelta(hours = int(shiftCList[0]), minutes = int(shiftCList[1]) - 1):
  39. print(9)
  40. file = 'python /quad/finalMachineEfficiency.py '+ eachClient['clientId'] + ' ' + timeInSecondsList[0] + ':' + timeInSecondsList[1] + ' ' + dateTime
  41. os.system(file)
  42. print(os.system(file))
  43. if time == timedelta(hours = int(shiftAList[0]), minutes = int(shiftAList[1]) - 1):
  44. print(10)
  45. file = 'python /quad/finalMachineEfficiency.py '+ eachClient['clientId'] + ' ' + timeInSecondsList[0] + ':' + timeInSecondsList[1] + ' ' + dateTimeYesterday
  46. os.system(file)
  47. file2 = 'python /quad/finalOee.py ' + eachClient['clientId'] + ' ' + timeInSecondsList[0] + ':' + timeInSecondsList[1] + ' ' + dateTimeYesterday
  48. os.system(file2)
  49. print(os.system(file), os.system(file2))
  50. print("callefficiency.py ended", dateTime)
  51.  
  52. callefficiency.py started
  53. 1
  54. 2
  55. 3
  56. 4
  57. 5
  58. 6
  59. 7
  60. 10
  61. 256 256
  62. 6
  63. 7
  64. 10
  65. 256 256
  66. 6
  67. 7
  68. 10
  69. 256 256
  70. 6
  71. 7
  72. 10
  73. 256 256
  74. callefficiency.py ended 2017-12-15
Add Comment
Please, Sign In to add comment