def webhook(): # return "bitch9" # return Response(status=200) data = request.form mac = data['mac'] print("huheufe") datawithoutmac = {} for i in data: if i != "mac": datawithoutmac[i] = data[i] message = "|".join( v for k, v in sorted(datawithoutmac.items(), key=lambda x: x[0].lower())) mac_calculated = hmac.new("ce1a51c7f875438cbbfcd35ea5533128", message, hashlib.sha1).hexdigest() if mac == mac_calculated: if data['status'] == 'Credit': filename = data["buyer_name"].split( " ")[0] + "_" + data["payment_id"] + "_ticket.png" filepath = "tickets/" + filename WriteOnImage(data, filepath) sendemail(data, filename) else: #payment failed pass return Response(status=200) else: return Response(status=400)
def WriteOnImage(data): count = 0 for det in data: count = 91 # if(count==50): # return #det[0] is the name, det[1] is the email id, det[2] is the price of the ticket img = "./tickets/" print(det) if (int(det[2]) == int(600)): img += str(det[2]) img += ".jpg" # print(img) elif (int(det[2]) == 700): img += str(det[2]) img += ".jpg" # print(img) elif (int(det[2]) == 1000): img += str(det[2]) img += ".jpg" # print(img) elif (int(det[2]) == 1100): img += str(det[2]) img += ".jpg" # print(img) # else: # # img+=str(det[2]) # img+="test.jpg" # print(img) # return # img = Image.open("./tickets/1100.jpg") imgo = Image.open(img) imgo.show() draw = ImageDraw.Draw(imgo) font = ImageFont.truetype("./static/olivia.otf", 45) # name = data["buyer_name"] # name=det[0].split(" ") # name="blahblha blahhsadflksadjf" names = det[0].split(" ") if (len(names) == 2): firstname, lastname = names[0], names[1] toprint = firstname + "\n" + lastname else: firstname = names[0] toprint = firstname draw.text((1347, 152), toprint, (255, 255, 255), font=font) filename = "./tickets/new/" filename += firstname + "_" + str(det[2]) + "_" + str(count) + ".jpg" print(filename) imgo.save(filename) sendemail(data)
def main(): initLogger() with open('auth', 'r', encoding='utf8') as fh: user = fh.readline().strip() password = fh.readline().strip() if '-c' in sys.argv or 'captcha' in sys.argv: captcha = True else: captcha = False c = Cli(user, password, captcha) reauth = False while True: try: if reauth: c.auth() reauth = False courseid = c.enroll() if not courseid: break c.courseid = courseid time.sleep(random.randint(Config.minIdle, Config.maxIdle)) except IndexError as e: c.logger.info("Course not found, maybe not start yet") time.sleep(random.randint(Config.minIdle, Config.maxIdle)) except KeyboardInterrupt as e: c.logger.info('user abored') break except (NetworkSucks, requests.exceptions.ConnectionError, requests.exceptions.ConnectTimeout) as e: c.logger.debug('network error') except AuthInvalid as e: c.logger.error('wait for user operating') reauth = True time.sleep(Config.waitForUser) # reauth next loop except Exception as e: c.logger.error(repr(e)) if ('-m' in sys.argv or 'mail' in sys.argv) and os.path.exists('mailconfig'): with open('mailconfig', 'rb') as fh: user = fh.readline().strip() pwd = fh.readline().strip() smtpServer = fh.readline().strip() receiver = fh.readline().strip() sendemail(user, pwd, smtpServer, receiver)
def createticket(name, email): names = name.split(" ") firstname = names[0] lastname = "" for x in names[1:]: lastname += x + " " img = Image.open("./static/ticket.png") draw = ImageDraw.Draw(img) font = ImageFont.truetype("./static/olivia.otf", 17) toprint = firstname + "\n" + lastname draw.text((510, 60), toprint, (255, 255, 255), font=font) filename = "offline_" + firstname + "_" + lastname + "_ticket.png" filepath = "./tickets/" + filename img.save(filepath) data = {"buyer": email} sendemail(data, filename) return "E-mail sent to " + email
import xlrd from writeonimage import WriteOnImage from mailer import sendemail # Give the location of the file loc = ("./tickets/names.xlsx") # To open Workbook wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # For row 0 and column 0 details=[] for k in range(1,91): name=sheet.cell_value(k, 1) email=sheet.cell_value(k,3) price=int(sheet.cell_value(k,5)) details.append([name,email,price]) print(len(details)) sendemail(details) # WriteOnImage(details)