def xls_to_pdf_publisher(xls_file, pdf_file, sent_to_print, script_path, pause): result = 4 if os.path.exists(xls_file): loader.logger.writeLog('File found: ' + str(xls_file)) loader.logger.writeLog('Try to save to: ' + str(pdf_file)) try: if loader.KEY or loader.NOT_KEY(): subprocess.call("cmd /c " + script_path + " " + xls_file) result = 1 if sent_to_print == 1: pdf_file = pdf_file.replace("/", "\\") if loader.KEY or loader.NOT_KEY(): os.startfile(pdf_file, 'print') result = 1 loader.logger.writeLog( " Waiting to Printer....") time.sleep(pause) os.system("taskkill /im AcroRd32.exe /f") return result except: loader.logger.writeLog( " ---xls_to_pdf_publisher--- Unexpected error: " + str(sys.exc_info()[0])) else: loader.logger.writeLog('File Not found: ' + str(xls_file)) result = 4 # updater(idx, 4, "Waiting for ExcelFile") return result
def getrow(self, query): cursorOra = self.dbOra.cursor() rs = cursorOra.execute(query) if loader.KEY or loader.NOT_KEY(): return rows_to_dict_list(cursorOra)[0] else: return dict()
def getrow(self, query): cursorSQL = self.dbSQL.cursor() cursorSQL.execute(query) columns = [column[0] for column in cursorSQL.description] results = [dict(zip(columns, cursorSQL.fetchone()))] if loader.KEY or loader.NOT_KEY(): return results[0] else: return dict()
def getrows(self, query): cursorSQL = self.dbSQL.cursor() cursorSQL.execute(query) columns = [column[0] for column in cursorSQL.description] results = [] for row in cursorSQL.fetchall(): if loader.KEY or loader.NOT_KEY(): results.append(dict(zip(columns, row))) return results
def getTagValue(self, tag_name): self.client.connect() tag = self.client.get_node(tag_name) value = tag.get_value() self.client.disconnect() if loader.KEY or loader.NOT_KEY(): return value else: return -1
def setrow(self, query): cursorOra = self.dbOra.cursor() if loader.KEY or loader.NOT_KEY(): cursorOra.execute(query)
def setrow(self, query): cursorSQL = self.dbSQL.cursor() if loader.KEY or loader.NOT_KEY(): cursorSQL.execute(query) self.dbSQL.commit()
def html_mailer(subject, body, to_address, cc_address, station, file, path): file = str(file) path = str(path) try: outlook = win32.Dispatch('outlook.application') mail = outlook.CreateItem(0) if to_address is not None: mail.To = to_address else: to_address = '' if cc_address is not None: mail.CC = cc_address else: cc_address = '' if file is not None and path is not None: loader.logger.writeLog( " Looking at Dir - '" + path) loader.logger.writeLog( " for File - '" + file) if file.find("**") == 0: if os.path.exists(path): for fileName in os.listdir(path): attachment = path + fileName loader.logger.writeLog( " Preparing File: " + attachment) mail.Attachments.Add(attachment) elif file.find("*") > 0: if os.path.exists(path): for fileName in os.listdir(path): if fnmatch.fnmatch(fileName, file): attachment = path + fileName loader.logger.writeLog( " Preparing File: " + attachment) mail.Attachments.Add(attachment) else: if os.path.exists(path + file): attachment = path + file loader.logger.writeLog( " Preparing File: " + attachment + ". PID ") mail.Attachments.Add(attachment) loader.logger.writeLog(" Mail Message.") loader.logger.writeLog(" To: " + to_address) loader.logger.writeLog(" CC: " + cc_address) loader.logger.writeLog(" Subject: " + subject) HTMLBody = "" f = open('MailSignature.html', "r") if f.mode == 'r': HTMLBody = f.read() HTMLBody = HTMLBody.replace("%Station", station) HTMLBody = HTMLBody.replace("%Body", body) # print(HTMLBody) mail.HTMLBody = HTMLBody mail.Subject = subject if loader.KEY or loader.NOT_KEY(): mail.Send() loader.logger.writeLog(" Mail Done!. PID ") return True except: loader.logger.writeLog( " ---html_mailer--- Unexpected error: " + str(sys.exc_info()[0])) return False