-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.py
More file actions
119 lines (100 loc) · 2.62 KB
/
menu.py
File metadata and controls
119 lines (100 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import os
import random
from smtplib import *
import time
import pdb
import sqlite3
from LongestCommonSubStr import *
pwd = os.path.join(os.getcwd(), "menu2.txt")
file = open(pwd, 'r')
dbfile = os.path.join(os.getcwd(), "menu")
#conn = sqlite3.connect(dbfile)
#c = conn.cursor()
outStr = "we will eat this :\n"
ISOTIMEFORMAT='%Y-%m-%d %X'
dict = {}
list = []
#targets = ["yangjiandong@snda.com", "lijian01@snda.com", "gaoyong01@snda.com", "v.huangcheng01@snda.com",
# "lichencheng@snda.com", "chensiru@snda.com", "v.yangjiamin@snda.com", "v.zhaojiajia@snda.com",
# "sujiqiang@snda.com", "sunning@snda.com"]
#targets = ["yangjiandong@snda.com","sunning@snda.com"]
#define this:
meat = 6
veg = 2
n = 59
m = 80
sum = 0
ltmp = time.localtime()
aDate = time.strftime(ISOTIMEFORMAT, time.localtime())
if ltmp[3] < 13:
aTime = 'lunch'
else:
aTime = 'dinner'
while True:
line = file.readline()
if line:
if (line != '\n'):
(name, price) = line.split()
dict[name] = int(price)
list.append(name)
#print name
else:
#print 'hell'
break
file.close()
outStr += '\nmeat is: \n'
#print '\nmeat: '
lmenu = [' ']
flag = True
#pdb.set_trace()
i = 0
while i < meat:
flag = True
ran = random.randint(0, n)
for sName in lmenu:
(max, min) = rangeLen(sName, list[ran])
aStr = lcs(max, min)
if (len(aStr) > 3):
flag = False
if flag == True:
i = i + 1
sum += dict[list[ran]]
outStr += list[ran]
outStr += '\n'
lmenu.append(list[ran])
list[ran] = list[n]
--n
#print '\nvebetables is : '
outStr += '\nvegetables is : \n'
i = 0
while i < veg:
flag = True
ran = random.randint(n+1, m)
for sName in lmenu:
(max, min) = rangeLen(sName, list[ran])
aStr = lcs(max, min)
if (len(aStr) > 3):
flag = False
if flag == True:
i = i + 1
sum += dict[list[ran]]
outStr += list[ran]
outStr += '\n'
lmenu.append(list[ran])
list[ran] = list[m]
--m
# print dict
#print 'the total money is : %d\n' % sum
#tmp = (unicode(aDate), unicode(aTime), unicode(outStr), sum)
#c.execute('insert into menu values (?,?,?,?)', tmp)
#conn.commit()
#c.close()
outStr += 'the total money is : %d\n' % sum
outStr += '\n'
print outStr
head = 'Subject: menu order\nContent-Type: text/plain; charset=UTF-8\n\n\r'
mailcontent = (head + outStr + '%s ' % (time.asctime(),))
#smtp = SMTP("61.172.242.25")
#smtp.sendmail("yangjiandong@sdo.com", targets, mailcontent)
#smtp.quit()
#print "mail sent @ %s." % time.asctime()