class MessageAttribute(object): # A list of MIME-encoded attachments. #attachments = [] # The visible author of the message. This maps to the From: header. author = '' # The visible list of primary intended recipients. to = [] # A visible list of secondary intended recipients. cc = [] # An invisible list of tertiary intended recipients. bcc = [] # The visible date/time of the message, defaults to datetime.now() date = datetime.now() # A list of MIME-encoded embedded images. #embedded = [] # Unicode encoding, defaults to utf-8. encoding = 'utf-8' # A list of additional message headers. headers = [] # The address that message disposition notification messages get routed to. notify = '' # An extended header for an organization name. organization = '' # The X-Priority header. priority = [] # The address replies should be routed to by default; reply = [] # The number of times the message should be retried in the event of a # non-critical failure. retries = 0 # The designated sender of the message; may differ from author. This is # primarily utilized by SMTP delivery. sender = '' # The subject of the message. subject = ''
def testConversions(self): sdt0 = datetime.now() # this is a timezone naive datetime dt0 = DateTime(sdt0) self.assertTrue(dt0.timezoneNaive(), (sdt0, dt0)) sdt1 = datetime(2007, 10, 4, 18, 14, 42, 580, pytz.utc) dt1 = DateTime(sdt1) self.assertFalse(dt1.timezoneNaive(), (sdt1, dt1)) # convert back sdt2 = dt0.asdatetime() self.assertEqual(sdt0, sdt2) sdt3 = dt1.utcdatetime() # this returns a timezone naive datetime self.assertEqual(sdt1.hour, sdt3.hour) dt4 = DateTime('2007-10-04T10:00:00+05:00') sdt4 = datetime(2007, 10, 4, 5, 0) self.assertEqual(dt4.utcdatetime(), sdt4) self.assertEqual(dt4.asdatetime(), sdt4.replace(tzinfo=pytz.utc)) dt5 = DateTime('2007-10-23 10:00:00 US/Eastern') tz = pytz.timezone('US/Eastern') sdt5 = datetime(2007, 10, 23, 10, 0, tzinfo=tz) dt6 = DateTime(sdt5) self.assertEqual(dt5.asdatetime(), sdt5) self.assertEqual(dt6.asdatetime(), sdt5) self.assertEqual(dt5, dt6) self.assertEqual(dt5.asdatetime().tzinfo, tz) self.assertEqual(dt6.asdatetime().tzinfo, tz)
def payment(cursor, conn): ptno = input('Please enter the ticket number for the ticket that is being paid') cursor.execute('select fine from tickets where tno = ?;', (ptno,)) tfine = cursor.fetchone() if tfine == None: print('Invalid ticket number') return 0 tfine = float(tfine) pamount = input('Please enter the ticket amount') cursor.execute()#missing sql statement should collect a sum of payments with ptno my brain died and couldn't get it working :( psum = cursor.fetchone() if (pamount + psum) > tfine: pmax = tfine - psum print('Invalid payment:too high max payment for this fine is ' + pmax) return 0 pdate = datetime.date(datetime.now()) pdate = pdate.strftime('%Y-%m-%d') cursor.execute('insert into payments values (?, ?, ?,);', (ptno, pdate, pamount)) conn.commit()
def sellCar(cursor, conn): ofname = input('Please enter the first name of the old owner') olname = input('Please enter the last name of the old owner') nfname = input('Please enter the first name of the new owner') nlname = input('Please enter the last name of the new owner') cvin = input('Please enter the vin of the car') cursor.execute('select * from registrations where vin = ?;', (cvin,)) check = cursor.fetchone() if check == None: print('Invalid vin') return 0 cursor.execute('select fname from registrations where vin = ? order by regdate DESC limit 1;', (cvin,)) cfname = cursor.fetchone() cursor.execute('select lname from registrations where vin = ? order by regdate DESC limit 1;', (cvin,)) clname = cursor.fetchone() if cfname != ofname or clname != olname: print('Invalid seller') return 0 nplate = input('Please enter the new plate number') oexpdate = datetime.date(datetime.now()) nexpdate = oexpdate nexpdate = nexpdate.replace( year = nexpdate.year + 1) oexpdate = oexpdate.strftime('%Y-%m-%d') nexpdate = nexpdate.strftime('%Y-%m-%d') cursor.execute('select regno from registrations where vin = ? order by regdate DESC limit 1;', (cvin,)) oregno = cursor.fetchone() cursor.execute('update registrations set expiry = ? where regno = ?;', (oexpdate,), (oregno,)) nregno = random.randint(100000, 999999) cursor.execute('select * from registrations where regno = ?;', (nregno,)) check2 = cursor.fetchone() if check2 != None: while check2 != None: nregno = random.randint(100000, 999999) cursor.execute('select * from registrations where regno = ?;', (nregno,)) check2 = cusor.fetchone() cursor.execute('insert into registrations values (?, ?, ?, ?, ?, ?, ?);', (nregno, oexpdate, nexpdate, nplate, cvin, nfname, nlname)) conn.commit()
def renew_vregistration(cursor, conn): vregno = input('Please enter the vehicles registration number') today = datetime.date(datetime.now()) exp = None while exp == None: cursor.execute('select r.expiry from registrations r where r.regno = ?;', (vregno,)) exp = cursor.fetchone() if exp = None: vregno = input('Please enter a valid registration number')
def appointmentApp(): symptoms = request.form['symptoms'] doctor_id = request.form['doctor_id'] slot_id = request.form['slot_id'] patient_id = session[] try: id = timestamp = datetime.now() newApp = Application(id, timestamp, symptoms, 'pending', None, slot_id, doctor_id, None, patient_id) db.session.add(newApp) db.commit() return 'submitted' except: return render_template('application.html', error='application failed')
def registerMarriage(cursor, conn): p1Fname = input('Please enter the first name of Partner 1') p1Lname = input('Please enter the last name of Partner 1') p2Fname = input('Please enter the first name of Partner 2') p2Lname = input('Please enter the last name of Partner 2') mregdate = datetime.date(datetime.now()) mregdate = mregdate.strftime('%Y-%m-%d') mregno = random.randint(100000,999999) row = None cursor.execute('select * from marriages m where m.regno = ?;', (mregno,)) row = cursor.fetchone() if row != None: while row != None: mregno = random.randint(100000,999999) row = None cursor.execute('select * from marriages m where m.regno = ?;', (mregno,)) row = cursor.fetchone() row = None cursor.execute('select * from persons p where p.fname = ? and p.lname = ?;',(p1Fname,), (p1Lname,)) row = cursor.fetchone() if row == None: print('Partner 1 info missing please enter the missing data') paFname = input('Please enter the first name of Partner 1') paLname = input('Please enter the last name of Partner 1') pabDate = input('Please enter the birthdate of Partner 1') pabPlace = input('Please enter the birthplace of Partner 1') paAddress = input('Please enter the address of Partner 1') paPhone = input('Please enter the phone number of Partner 1') cursor.execute('insert into persons values (?, ?, ?, ?, ?, ?);', (paFname, paLname, pabDate, pabPlace, paAddress, paPhone)) conn.commit() row = None cursor.execute('select * from persons p where p.fname = ? and p.lname = ?;',(p2Fname,), (p2Lname,)) row = cursor.fetchone() if row == None: print('Partner 2 info missing please enter the missing data') paFname = input('Please enter the first name of Partner 2') paLname = input('Please enter the last name of Partner 2') pabDate = input('Please enter the birthdate of Partner 2') pabPlace = input('Please enter the birthplace of Partner 2') paAddress = input('Please enter the address of Partner 2') paPhone = input('Please enter the phone number of Partner 2') cursor.execute('insert into persons values (?, ?, ?, ?, ?, ?);', (paFname, paLname, pabDate, pabPlace, paAddress, paPhone)) conn.commit() cursor.execute('inset into marriages values (?, ?, ?, ?, ?, ?, ?);', (mregno, mregdate, mregplace, p1Fname, p1Lname, p2Fname, p2Lname)) conn.commit()
def register_birth(cursor, conn, login): bregno = random.randint(100000,999999) row = None cursor.execute('select * from births b where b.regno = ?;', (bregno,)) row = cursor.fetchone() if row != None: while row != None: bregno = random.randint(100000,999999) row = None cursor.execute('select * from births b where b.regno = ?;', (bregno,)) row = cursor.fetchone() bfname = input('What is the first name of the baby') blname = input('What is the last name of the baby') bregdate = datetime.date(datetime.now()) bregdate = bregdate.strftime('%Y-%m-%d') cursor.execute('select u.city from users u where u.uid = ?;', (login,)) bregplace = cursor.fetchone() nbplace = input('What is the birth place') bgender = 'l' while bgender != 'M' or bgender != 'F': bgender = input('What is the gender of the child (M or F)?') bgender = bgender.upper() p1Fname = input('What is the first name the Mother') p1Lname = input('What is the last name of the Mother') #check if parent 1 exists row = None cursor.execute('select * from persons p where p.fname = ? and p.lname = ?;',(p1Fname,), (p1Lname,)) row = cursor.fetchone() if row == None: print('Mother info missing please enter the missing data') paFname = input('Please enter the first name of Mother') paLname = input('Please enter the last name of Mother') pabDate = input('Please enter the birthdate of Mother') pabPlace = input('Please enter the birthplace of Mother') paAddress = input('Please enter the address of Mother') paPhone = input('Please enter the phone number of Mother') cursor.execute('insert into persons values (?, ?, ?, ?, ?, ?);', (paFname, paLname, pabDate, pabPlace, paAddress, paPhone)) conn.commit() p2Fname = input('What is the first name of the Father') p2Lname = input('What is the last name of the Father') #check existence of Father cursor.execute('select * from persons p where p.fname = ? and p.lname = ?',(p2Fname,), (p2Lname,)) row = cursor.fetchone() if row == None: print('Father info missing please enter the missing data') paFname = input('Please enter the first name of Father') paLname = input('Please enter the last name of Father') pabDate = input('Please enter the birthdate of Father') pabPlace = input('Please enter the birthplace of Father') paAddress = input('Please enter the address of Father') paPhone = input('Please enter the phone number of Father') cursor.execute('insert into persons values (?, ?, ?, ?, ?, ?);', (paFname, paLname, pabDate, pabPlace, paAddress, paPhone)) conn.commit() cursor.execute('insert into births values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);', (bregno, bfname, blname, bregdate, bregplace, bgender, p1Fname, p1Lname, p2Fname, p2Lname)) conn.commit() #create the persons entry nbdate = input('Please enter the birthdate of the baby') cursor.execute('select p.address from persons p where p.fname = ? and p.lname = ?;', (p1Fname, p1Lname)) baddress = cursor.fetchone() cursor.execute('select p.phone from persons p where p.fname = ? and p.lname = ?;', (p1Fname, p1Lname)) bphone = cursor.fetchone() cursor.execute('insert into persons values (?, ?, ?, ?, ?, ?);', (bfname, blname, nbdate, nbplace, baddress, bphone)) conn.commit()
import sys import socket from date time import datetime #define a target if len(sys.argv)==2 target = socket.gethostnamebyname(sys.argv[1]) #translate host name to ip address esle: print ("invalid amount of arguments") print (" Syntax: pyhton3 scanner.pu <ip>") #add a pretty banner print("-"*50) print( "scanning target " + target) print ("time started : " + str(datetime.now())) print("-"*50) try: for port in range (1,100): s=socket.socket(socket.AF_NET, socket.SOCK_STREAM) socket.setdefaulttimeout(1) result=s.connect_ex((target, port)) if result==0: print("port {} is open" .format(port)) s.close() except KeyInterrupt: print("exiting program") s.exit() except socket.gaierror: print("hostname could not be resolved") s.exit()