-
Notifications
You must be signed in to change notification settings - Fork 0
/
whaiout.py
293 lines (180 loc) · 4.78 KB
/
whaiout.py
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>
# <markdowncell>
# <h3>WhaiOut</h3>
#
# This is the signout script that opens the login file and fills in signout info.
#
# Opens up list of signin data. This is date of sign in, time, name, and reason.
# This is .meta. This script appends sign out data. This is signout date, signout time, and comments.
#
# 8 urandom 128 keys are generated. Used these in saving the achieve, as .html, and .meta files.
# Why not save as yr-month-day-hr-min.meta /html
#
# Turn it into a Nikola blog. Three blog posts. login (whaxlu.py), logout (whaiout.py), and the result of both of them. Perhaps it
#
# creates date and time mark and asks for comment
# <markdowncell>
# This needs rewriten to remove xl stuff opening. keep it to json and dict.
# <codecell>
#import xlrd
import os
import time
#from xlutils.copy import copy
#from xlrd import *
import dominate
import json
from dominate.tags import *
from time import strftime, gmtime
# <codecell>
#wrkbook = xlrd.open_workbook('/home/wcmckee/whai/index.xls')
# <codecell>
jsopn = open('/home/wcmckee/visignsys/index.json', 'r')
jsrdv = jsopn.read()
# <codecell>
jsrdv
# <codecell>
#print wrkbook.sheet_names()
#worksheet = wrkbook.sheet_by_name('visitor sign database')
#swlis = []
#num_rows = worksheet.nrows - 1
#curr_row = -1
#while curr_row < num_rows:
# curr_row += 1
# row = worksheet.row(curr_row)
#print row
# swlis.append(row)
# <codecell>
#valis = []
# <codecell>
#for swl in swlis[1]:
# print swl.value
# valis.append(swl.value)
# <codecell>
tiran = os.urandom(128).encode('hex')
reran = os.urandom(128).encode('hex')
comran = os.urandom(128).encode('hex')
# <codecell>
inpcom = raw_input('comment: ')
# <codecell>
endate = time.strftime("%d" + "-" + "%b" + "-" + "%Y")
entim = time.strftime("%H:%M")
# <codecell>
snoutm = {'out-date': endate}
snoutm.update({'out-time': entim})
snoutm.update({'out-comment': inpcom})
# <codecell>
signoutdic = {endate: tiran}
timoutdic = {entim: reran}
# <codecell>
signoutdic.update({entim:reran})
# <codecell>
signoutdic.update({inpcom: comran})
# <codecell>
signkeys = signoutdic.keys()
# <codecell>
wha = open('/home/wcmckee/visignsys/index.json', 'a')
#w = copy(open_workbook('/home/wcmckee/whai/index.xls'))
#w.get_sheet(0).write(1,5, time.strftime("%d" + "-" + "%b" + "-" + "%Y"))
#w.get_sheet(0).write(1,6, time.strftime("%H:%M"))
#w.get_sheet(0).write(1,7, tiran)
#w.save('/home/wcmckee/whai/index.xls')
# <codecell>
indsav = ('/home/wcmckee/whai/index.html')
# <codecell>
opind = open(indsav, 'w')
# <codecell>
doc = dominate.document(title=wrkbook.sheet_names())
with doc.head:
link(rel='stylesheet', href='style.css')
script(type='text/javascript', src='script.js')
with doc:
with div(id='header').add(ol()):
for i in valis:
li(a(i))
with div():
attr(cls='body')
p('visitor sign database is open source. Visit https://github.com/wcmckee/wcmckee ')
#print doc
# <codecell>
opind.write(str(doc))
# <codecell>
opind.close()
# <codecell>
liop = open('/home/wcmckee/visignsys/index.meta', 'a+')
liop.write(str(signkeys))
liop.close()
# <codecell>
# <codecell>
oplis = open('/home/wcmckee/visignsys/index.meta', 'r')
oplsav = oplis.read()
oplis.close()
# <codecell>
trsor = tiran[0:12]
# <codecell>
yearz = strftime("%y", gmtime())
monthz = strftime("%m", gmtime())
dayz = strftime("%d", gmtime())
hurz = strftime("%H", gmtime())
minz = strftime("%M", gmtime())
# <codecell>
dform = (yearz + monthz + dayz +hurz + minz)
# <codecell>
optrd = open('/home/wcmckee/visignsys/posts/' + dform + '.meta', 'w')
optrd.write(oplsav)
optrd.close()
# <codecell>
jsnrd = open('/home/wcmckee/visignsys/posts/' + dform + '.json', 'w')
jsnrd.write(oplsav)
jsnrd.close()
# <codecell>
savpos = open('/home/wcmckee/visignsys/index.json', 'r')
signindi = savpos.read()
# <codecell>
jsnaccept = signindi.replace("'", "\"")
snoutm = json.loads(jsnaccept)
# <codecell>
snct = dict(d.items() + snoutm.items())
# <codecell>
savpos.close()
# <codecell>
os.chdir('/home/wcmckee/visignsys/posts')
# <codecell>
lismet = os.listdir('/home/wcmckee/visignsys/posts')
# <codecell>
lismet
# <codecell>
opjsnz = []
# <codecell>
for beca in lismet:
if '.json' in beca:
print beca
opjsnz.append(beca)
# <codecell>
optjz = []
optjsz = []
# <codecell>
apgpls = []
# <codecell>
#for opjw in opjsnz:
# print opjw
# optjsz.append(objw)
# <codecell>
#for filop in opjsnz:
#print filop
# opt = open(opj, 'r')
# thedict = str(opt.read())
# thedict
# opt.close()
# <codecell>
#opt = open(opj, 'r')
# <codecell>
#thedict = opt.read()
# <codecell>
#thedict
# <codecell>
#convgpj = json.loads(thedict)
# <codecell>
#convgpj.values()
# <codecell>
# <codecell>