whaiout

This is the signout script that opens the xl file and fill 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.

creates date and time mark and asks for comment

This needs rewriten to remove xl stuff opening. keep it to json and dict.

In [1]:
#import xlrd
import os
import time
#from xlutils.copy import copy
#from xlrd import *
import dominate
import json
In [2]:
#wrkbook = xlrd.open_workbook('/home/wcmckee/whai/index.xls')
In [3]:
jsopn = open('/home/wcmckee/visignsys/index.json', 'r')
jsrdv = jsopn.read()
In [4]:
jsrdv
Out[4]:
'{"signin hrmin": "15:09:51", "reason": "ESW", "firstname": "William", "signin comment": "sunny and mum is back", "lastname": "Mckee", "signin date": "02-Dec-2014"}{"signin-date": "09-Dec-2014", "reason": "esw", "signin-comment": "checking this on the bus", "last-name": "mckee", "signin-hrmin": "08:30:54"}'
In [5]:
#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)
In [6]:
#valis = []
In [7]:
#for swl in swlis[1]:
#    print swl.value
#    valis.append(swl.value)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-7-4f71789a25a2> in <module>()
----> 1 for swl in swlis[1]:
      2     print swl.value
      3     valis.append(swl.value)

NameError: name 'swlis' is not defined
In [8]:
tiran = os.urandom(128).encode('hex')
reran = os.urandom(128).encode('hex')
comran = os.urandom(128).encode('hex')
In [7]:
inpcom = raw_input('comment: ')
comment: chexk
In [8]:
endate = time.strftime("%d" + "-" + "%b" + "-" + "%Y")
          
entim = time.strftime("%H:%M")
In [9]:
snoutm = {'out-date': endate}
snoutm.update({'out-time': entim})
snoutm.update({'out-comment': inpcom})
In [10]:
signoutdic = {endate: tiran}
timoutdic = {entim: reran}
In [11]:
signoutdic.update({entim:reran})
In [12]:
signoutdic.update({inpcom: comran})
In [13]:
signkeys = signoutdic.keys()
In [14]:
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')
In [15]:
indsav = ('/home/wcmckee/whai/index.html')
In [16]:
opind = open(indsav, 'w')
In [17]:
import dominate
from dominate.tags import *

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
In [18]:
opind.write(str(doc))
In [19]:
opind.close()
In [20]:
liop = open('/home/wcmckee/visignsys/index.meta', 'a+')
liop.write(str(signkeys))
liop.close()
In [80]:
 
In [81]:
oplis = open('/home/wcmckee/visignsys/index.meta', 'r')
oplsav = oplis.read()
oplis.close()
In [82]:
trsor = tiran[0:12]
In [83]:
trsor
Out[83]:
'413c61c9654e'
In [84]:
optrd = open('/home/wcmckee/visignsys/posts/' + trsor + '.meta', 'w')
optrd.write(oplsav)
optrd.close()
In [85]:
jsnrd = open('/home/wcmckee/visignsys/posts/' + trsor + '.json', 'w')
jsnrd.write(oplsav)
jsnrd.close()
In [86]:
savpos = open('/home/wcmckee/visignsys/index.json', 'r')
signindi = savpos.read()
---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-86-011d26fbe418> in <module>()
----> 1 savpos = open('/home/wcmckee/visignsys/index.json', 'r')
      2 signindi = savpos.read()

IOError: [Errno 2] No such file or directory: '/home/wcmckee/visignsys/index.json'
In [87]:
jsnaccept = signindi.replace("'", "\"")
d = json.loads(jsnaccept)
In [88]:
snct = dict(d.items() + snoutm.items())
In [89]:
savpos.close()
In [90]:
os.chdir('/home/wcmckee/visignsys/posts')
In [91]:
lismet = os.listdir('/home/wcmckee/visignsys/posts')
In [92]:
lismet
Out[92]:
['df5aed94d944.meta',
 '5e98dfab4326.json',
 '8bf3b3c045b2.json',
 '5e98dfab4326.html',
 '2ce7b7e78b2d.meta',
 'a5fd59588711.html',
 '8bf3b3c045b2.meta',
 '4a1d7fbd4af7.html',
 '413c61c9654e.meta',
 '81ae6564478e.meta',
 '1ca6f0c7d074.html',
 'be7f3bba40a9.json',
 '1bca31594654.html',
 'be7f3bba40a9.html',
 '81ae6564478e.json',
 'be7f3bba40a9.meta',
 'd948bc2cb2d5.meta',
 '469b6be62e65.json',
 'f63a51c5660b.json',
 'f63a51c5660b.html',
 '4a1d7fbd4af7.json',
 'd7bfad4d84af.meta',
 '91ece852eb61.meta',
 '086ef98a8bea.meta',
 '231f0cbc6422.html',
 '413c61c9654e.json',
 '1ca6f0c7d074.meta',
 '5e98dfab4326.meta',
 '9479b52fcb96.meta',
 'a5fd59588711.meta',
 '6e8165886873.json',
 '3342b7e37622.json',
 '231f0cbc6422.meta',
 '1ca6f0c7d074.json',
 'd948bc2cb2d5.html',
 '4a1d7fbd4af7.meta',
 '6e8165886873.meta',
 'a5fd59588711.json',
 '6dbfbbb9c12e.html',
 '81ae6564478e.html',
 'd7bfad4d84af.json',
 '231f0cbc6422.json',
 'df5aed94d944.html',
 '469b6be62e65.meta',
 '9479b52fcb96.json',
 'f63a51c5660b.meta',
 '2ce7b7e78b2d.json',
 'df5aed94d944.json',
 '3342b7e37622.meta',
 '1bca31594654.meta',
 '1bca31594654.json',
 '6dbfbbb9c12e.meta',
 '086ef98a8bea.json',
 'd948bc2cb2d5.json']
In [99]:
opjsnz = []
In [100]:
for beca in lismet:
    if '.json' in beca:
        print beca
        opjsnz.append(beca)
5e98dfab4326.json
8bf3b3c045b2.json
be7f3bba40a9.json
81ae6564478e.json
469b6be62e65.json
f63a51c5660b.json
4a1d7fbd4af7.json
413c61c9654e.json
6e8165886873.json
3342b7e37622.json
1ca6f0c7d074.json
a5fd59588711.json
d7bfad4d84af.json
231f0cbc6422.json
9479b52fcb96.json
2ce7b7e78b2d.json
df5aed94d944.json
1bca31594654.json
086ef98a8bea.json
d948bc2cb2d5.json
In [121]:
optjz = []
optjsz = []
In [122]:
apgpls = []
In [124]:
#for opjw in opjsnz:
#    print opjw
#    optjsz.append(objw)
    
In [125]:
#for filop in opjsnz:
    #print filop
#    opt = open(opj, 'r')
#    thedict = str(opt.read())
#    thedict
#    opt.close()
In [126]:
#opt = open(opj, 'r')
In [127]:
#thedict = opt.read()
In [128]:
#thedict
Out[128]:
'{"signin hrmin": "19:11", "reason": "ESW", "name": "William Mckee", "signin date": "21-Oct-2014", "signin comment": "interested in watching swimmers on way back from walk"}'
In [129]:
#convgpj = json.loads(thedict)
In [130]:
#convgpj.values()
Out[130]:
[u'19:11',
 u'ESW',
 u'interested in watching swimmers on way back from walk',
 u'William Mckee',
 u'21-Oct-2014']
In [130]:
 
In [ ]:
 

Comments

Comments powered by Disqus