signinlca

script to signin for volunteers at lca2015


In [80]:
import os
import time
import json
import getpass

In [81]:
def returndate():
    return time.strftime(("%d" + "-" + "%b" + "-" + "%Y"))

def returntime():
    return time.strftime("%H:%M:%S")

In [67]:
firnam = raw_input('first name: ')
lasnam = raw_input('last name: ')
tshir = raw_input('tshirt size: ')
cofvol = raw_input('coffee volc: ')
comen = raw_input('comments: ')


first name: william
last name: mckee
tshirt size: L
coffee volc: 4
comments: doing av

In [68]:
betdict = dict()

In [69]:
betdict.update({'first-name' : firnam})
betdict.update({'last-name' : lasnam})
betdict.update({'signin-date' : returndate()})
betdict.update({'signin-hrmin' : returntime()})
betdict.update({'tshirt-size' : tshir})
betdict.update({'coffees' : int(cofvol)})
betdict.update({'comments:' : comen})

In [70]:
betdict


Out[70]:
{'coffees': 4,
 'comments:': 'doing av',
 'first-name': 'william',
 'last-name': 'mckee',
 'signin-date': '13-Jan-2015',
 'signin-hrmin': '07:30:32',
 'tshirt-size': 'L'}

In [71]:
convj = json.dumps(betdict)

In [72]:
convj


Out[72]:
'{"signin-date": "13-Jan-2015", "comments:": "doing av", "last-name": "mckee", "signin-hrmin": "07:30:32", "coffees": 4, "first-name": "william", "tshirt-size": "L"}'

In [73]:
puser = getpass.getuser()

In [73]:


In [74]:
signpath = ('/home/' + puser + '/signinlca')

In [75]:
if os.path.isdir(signpath) == True:
    print 'Path is there'
else:
    print 'Path not there'
    os.mkdir(signpath)


Path is there

In [76]:
os.chdir(signpath)

In [90]:
opday = open(str(returndate()) + '.json', 'a')

In [89]:
opday.write(convj)

In [ ]: