Skip to content

Commit

Permalink
Removed masterUpload from straw GUIs (#33)
Browse files Browse the repository at this point in the history
Clearing out old method of uploading data to a network, masterUpload. Updating MU2ECART directories.

* masterUpload removed from LeakTestGUI.py, resistanceGUI, CO2GUI, LazerGUI, SilverGUI.
* Updated old paths in the Verification/ area.
* Fixed paths from tempHumid.
  • Loading branch information
lealal authored Nov 18, 2020
1 parent 6ed6e22 commit 283306f
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 224 deletions.
41 changes: 4 additions & 37 deletions GUIS/straw/C02/CO2GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

import pyautogui
import time
import datetime
import os
import csv
import sys
from datetime import datetime
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
Expand All @@ -22,7 +22,6 @@

# import modules
from removeStraw import *
from masterUpload import *
from checkstraw import *

sys.path.insert(
Expand Down Expand Up @@ -129,13 +128,11 @@ def saveWorkers(self):
previousWorkers = []
activeWorkers = []
exists = os.path.exists(
self.workerDirectory + datetime.datetime.now().strftime("%Y-%m-%d") + ".csv"
self.workerDirectory + datetime.now().strftime("%Y-%m-%d") + ".csv"
)
if exists:
with open(
self.workerDirectory
+ datetime.datetime.now().strftime("%Y-%m-%d")
+ ".csv",
self.workerDirectory + datetime.now().strftime("%Y-%m-%d") + ".csv",
"r",
) as previous:
today = csv.reader(previous)
Expand All @@ -155,9 +152,7 @@ def saveWorkers(self):
if prev != self.justLogOut:
activeWorkers.append(prev)
with open(
self.workerDirectory
+ datetime.datetime.now().strftime("%Y-%m-%d")
+ ".csv",
self.workerDirectory + datetime.now().strftime("%Y-%m-%d") + ".csv",
"a+",
) as workers:
if exists:
Expand Down Expand Up @@ -417,34 +412,6 @@ def saveData(self):

QMessageBox.about(self, "Save", "Data saved successfully!")

def uploadData(self):
QMessageBox.about(self, "Upload", "Now attempting data upload.")

uploadWorker = self.sessionWorkers[0]
uploader = getUploader(self.stationID)("prod")
passed = True

for straw in self.straws:
if straw != "_______":
try:
uploader.beginUpload(
straw, uploadWorker, self.epoxyBatch, self.palletNum
)
except UploadFailedError as error:
passed = False
lastMessage = error.message

if passed:
QMessageBox.about(self, "Upload", "All data uploaded successfully!")
else:
QMessageBox.warning(
self,
"Upload Error",
"Some Uploads Failed\n\n"
+ lastMessage
+ "\n\nCheck 'errors.txt' for a complete list",
)

def resetGUI(self):
self.palletID = ""
self.palletNum = ""
Expand Down
65 changes: 9 additions & 56 deletions GUIS/straw/Laser/LazerGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
import csv
import sys
import threading
import datetime
import win32gui
import win32con

# import pyperclip
from datetime import datetime
from pathlib import Path
from PyQt5.QtCore import *
from PyQt5.QtGui import *
Expand Down Expand Up @@ -60,7 +60,6 @@
sys.path.insert(0, os.path.dirname(__file__) + "..\\")
from removeStraw import *
from checkstraw import *
from masterUpload import *


##**GLOBAL VARIABLES**##
Expand Down Expand Up @@ -304,7 +303,7 @@ def getTempHumid(self):
found = False
filename = ""
for entry in D:
if entry.startswith("464_" + datetime.datetime.now().strftime("%Y-%m-%d")):
if entry.startswith("464_" + datetime.now().strftime("%Y-%m-%d")):
filename = entry
found = True

Expand Down Expand Up @@ -363,9 +362,7 @@ def saveDummy(self):
time.sleep(1)
# print(MAIN_DIR)
pyautogui.typewrite(
MAIN_DIR
+ "Dummy Files\\"
+ datetime.datetime.now().strftime("%Y-%m-%d_%H_%M_%S")
MAIN_DIR + "Dummy Files\\" + datetime.now().strftime("%Y-%m-%d_%H_%M_%S")
)
time.sleep(0.5)
pyautogui.press("enter")
Expand Down Expand Up @@ -666,13 +663,11 @@ def saveWorkers(self):
previousWorkers = []
activeWorkers = []
exists = os.path.exists(
self.workerDirectory + datetime.datetime.now().strftime("%Y-%m-%d") + ".csv"
self.workerDirectory + datetime.now().strftime("%Y-%m-%d") + ".csv"
)
if exists:
with open(
self.workerDirectory
+ datetime.datetime.now().strftime("%Y-%m-%d")
+ ".csv",
self.workerDirectory + datetime.now().strftime("%Y-%m-%d") + ".csv",
"r",
) as previous:
today = csv.reader(previous)
Expand All @@ -692,9 +687,7 @@ def saveWorkers(self):
if prev != self.justLogOut:
activeWorkers.append(prev)
with open(
self.workerDirectory
+ datetime.datetime.now().strftime("%Y-%m-%d")
+ ".csv",
self.workerDirectory + datetime.now().strftime("%Y-%m-%d") + ".csv",
"a+",
) as workers:
if exists:
Expand Down Expand Up @@ -764,9 +757,7 @@ def saveData(self):
"a",
) as palletWrite:
palletWrite.write("\n")
palletWrite.write(
datetime.datetime.now().strftime("%Y-%m-%d_%H:%M") + ","
)
palletWrite.write(datetime.now().strftime("%Y-%m-%d_%H:%M") + ",")
palletWrite.write("lasr,")
for straw in self.straws:
palletWrite.write(straw)
Expand All @@ -781,9 +772,7 @@ def saveData(self):
"a",
) as palletWrite:
palletWrite.write("\n")
palletWrite.write(
datetime.datetime.now().strftime("%Y-%m-%d_%H:%M") + ","
)
palletWrite.write(datetime.now().strftime("%Y-%m-%d_%H:%M") + ",")
palletWrite.write("leng,")
for straw in self.straws:
palletWrite.write(straw)
Expand All @@ -797,7 +786,7 @@ def saveData(self):
with open(self.laserDirectory + self.palletNum + ".csv", "w+") as file:
header = "Timestamp, Pallet ID, Cut Type (0-4) or (2-6), Cut Temperature [C], Cut Humidity, workers ***NEWLINE***: Straw Names (24) ***NEWLINE***: Cut Lengths mm (24) ***NEWLINE***: Comments (optional)***\n"
file.write(header)
file.write(datetime.datetime.now().strftime("%Y-%m-%d_%H:%M") + ",")
file.write(datetime.now().strftime("%Y-%m-%d_%H:%M") + ",")
file.write(self.palletID + ",")
file.write(self.cutType + ",")
file.write(self.cutTemperature + ",")
Expand Down Expand Up @@ -828,42 +817,6 @@ def saveData(self):
# self.uploadData()
self.resetGUI()

def uploadData(self):
uploadWorker = self.sessionWorkers[0]

t = datetime.datetime.now()
t.strftime("%Y-%m-%d %H:%M")

lastMessage = ""

uploader = getUploader("leng")("prod")

for index, straw in enumerate(self.straws):
print("trying to upload" + straw)
try:
if straw != "_______":
uploader.beginUpload(
straw,
uploadWorker,
t,
self.cutTemperature,
self.cutHumidity,
self.cutLengths[index],
0,
self.palletNum,
)
except UploadFailedError as error:
lastMessage = error.message

if lastMessage != "":
QMessageBox.warning(
self,
"Upload Error",
"Some Uploads Failed\nOne example error message:\n\n"
+ lastMessage
+ "\n\nCheck 'errors.txt' for a complete list",
)

def editPallet(self):
rem = removeStraw(self.sessionWorkers)
rem.palletDirectory = self.palletDirectory
Expand Down
35 changes: 0 additions & 35 deletions GUIS/straw/Leak/LeakTestGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,8 @@
0, str(Path(Path(__file__).resolve().parent.parent.parent.parent / "Data"))
)
from workers.credentials.credentials import Credentials

from remove import Ui_DialogBox

# move up one directory
sys.path.insert(0, os.path.dirname(__file__) + "..\\")
from masterUpload import *


import threading


Expand Down Expand Up @@ -1437,35 +1431,6 @@ def getCPALS(self):

return

def strawUpload(self, chamber):
ROW = int(chamber / 5)
COL = chamber % 5

strawname = self.Choosenames[ROW][COL][:7]
# strawname = strawname.upper()

uploadWorker = self.getWorker()

leakrate = self.leak_rate[chamber]
uncertainty = self.leak_rate_err[chamber]
currenttime = datetime.datetime.now().strftime("%m-%d-%Y %H:%M:%S")
(_, cpal) = FindCPAL(strawname)

uploader = getUploader(self.stationID)("prod")

try:
uploader.beginUpload(
strawname,
uploadWorker,
leakrate,
uncertainty,
currenttime,
chamber,
cpal,
)
except UploadFailedError as error:
self.FailedUpload.emit(strawname, error.message)

def editPallet(self):
if self.checkCredentials():
self.getCPALS()
Expand Down
41 changes: 0 additions & 41 deletions GUIS/straw/Resistance/resistanceGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
sys.path.insert(0, os.path.dirname(__file__) + "..\\")

# import modules
from masterUpload import *
from removeStraw import *

sys.path.insert(
Expand Down Expand Up @@ -871,46 +870,6 @@ def save(self):

QMessageBox.about(self, "Save", "Data saved successfully!")

def uploadData(self):
QMessageBox.about(self, "Upload", "Now attempting data upload.")

temp, humid = self.getTempHumid()
# temp, humid = 0, 0
uploadWorker = self.sessionWorkers[0]
uploader = getUploader(self.stationID)("prod")
passed = True

for straw_index, straw in enumerate(self.strawIDs):
if straw == None:
continue # Don't execute the code below
for measure_index in range(4):
try:
uploader.beginUpload(
straw,
uploadWorker,
temp,
humid,
self.measurements[straw_index][measure_index],
self.meas_type_labels_apprev[measure_index],
straw_index + 1,
self.palletNumber,
)

except UploadFailedError as error:
passed = False
last_message = error.message

if passed:
QMessageBox.about(self, "Upload", "All data uploaded successfully!")
else:
QMessageBox.warning(
self,
"Upload Error",
"Some Uploads Failed\n\n"
+ last_message
+ "\n\nCheck 'errors.txt' for a complete list",
)

def saveReset(self):
if self.measureByHand_counter < 2:
message = "There are some failed measurements. Would you like to try measuring by hand?"
Expand Down
Loading

0 comments on commit 283306f

Please sign in to comment.