def testunavailableextension(self): rawconfig = globalconfig.parseconfig(getcurrentdir() + "/filenameconfig.ini") print(getcurrentdir()) self.assertEqual( attachmentvalidations.validatefilename("watsup.xlsx2", rawconfig), False)
username = getrawconfig()[config_section]["username"] password = getrawconfig()[config_section]["password"] sender = '*****@*****.**' targets = ['*****@*****.**', '*****@*****.**'] msg = MIMEText(json.dumps({"watermark": value})) msg['Subject'] = 'Hello' msg['From'] = sender msg['To'] = ', '.join(targets) server = smtplib.SMTP_SSL(smtp_ssl_host, smtp_ssl_port) server.login(username, password) server.sendmail(sender, targets, msg.as_string()) server.quit() def makequeryforemailsaboveid(baseemailid, batchsize="*"): return "(UID {0}:{1})".format(str(baseemailid), str(batchsize)) def checkifwatermarkisgreaterthanlastid(watermark, lastid): return int(watermark) >= int(bytes.decode(lastid)) if __name__ == '__main__': globalconfig.parseconfig("../configs/config.ini") result, data = fetchemailsfrompreviouswatermark(75) mailids = data[0].split() for mid in mailids: downloadattachment(mid, "/tmp")
def testnonefile(self): rawconfig = globalconfig.parseconfig(getcurrentdir() + "/filenameconfig.ini") print(getcurrentdir()) self.assertEqual( attachmentvalidations.validatefilename(None, rawconfig), False)
thread.daemon = deamon print("starting timer thread") thread.start() return thread def servicerunner(): timerthread = runTimerThread() while True: if not timerthread.isAlive(): timerthread = runTimerThread() time.sleep(int(getrawconfig()["scrapetimer"]["buffer"])) def run(): # with daemon.basic_daemonize("pid.info"): servicerunner() if __name__ == '__main__': args = parse_argument() config_file_location = args.config globalconfig.parseconfig(config_file_location) storagemodule = importlib.import_module( "reliablestorage.{0}storage".format( getrawconfig()["watermark"]["storage"])) if args.service is None: runfrompreviouswatermark() else: run()