示例#1
0
def station_input():

    # check existing users for activity, delete inactive users
    inactive_users = []
    now = dt.datetime.today()

    # if inactive for longer than sessionlifetime, remove user from database
    sessionlifetime = 24 * 3600
    for uid in users:
        if (now - users[uid].last_activity_time).seconds > sessionlifetime:
            inactive_users.append(uid)
    for uid in inactive_users:
        del users[uid]
        rottendir = getgrowdir(uid)
        cmd = 'rm -rf ' + rottendir
        call(cmd, shell=True)

    # if this user has a history with Grow Hubway, get their directory
    if 'userid' in session:
        uid = session['userid']
        growdir = getgrowdir(uid)
    else:
        # otherwise, make a new userid with a random number generator
        # note, this solution may have problems related to collisions.  Need to
        # investigate this in the future
        uid = np.random.randint(1, high=1e8)

        # add the user id to the session dictionary
        session['userid'] = uid

        # get the users directory
        growdir = getgrowdir(uid)

        # make the directory
        cmd = 'mkdir ' + growdir
        call(cmd, shell=True)

    
    # store user class in users dictionary
    users[uid] = user.User()

    # reset to existing Hubway stations only
    gridpredict.resetiteration(basedir, growdir)

    # reset the results database for this user
    useraddress = []
    riderate = []
    dictnew = {"address": useraddress, "ridesperday": riderate}
    stations = pd.DataFrame(dictnew)
    stations.to_csv(growdir + 'appresults.csv', index=False)

    return render_template("input.html")
示例#2
0
def station_input():

    # check existing users for activity, delete inactive users
    inactive_users = []
    now = dt.datetime.today()

    # if inactive for longer than sessionlifetime, remove user from database
    sessionlifetime = 24 * 3600
    for uid in users:
        if (now - users[uid].last_activity_time).seconds > sessionlifetime:
            inactive_users.append(uid)
    for uid in inactive_users:
        del users[uid]
        rottendir = getgrowdir(uid)
        cmd = 'rm -rf ' + rottendir
        call(cmd, shell=True)

    # if this user has a history with Grow Hubway, get their directory
    if 'userid' in session:
        uid = session['userid']
        growdir = getgrowdir(uid)
    else:
        # otherwise, make a new userid with a random number generator
        # note, this solution may have problems related to collisions.  Need to
        # investigate this in the future
        uid = np.random.randint(1, high=1e8)

        # add the user id to the session dictionary
        session['userid'] = uid

        # get the users directory
        growdir = getgrowdir(uid)

        # make the directory
        cmd = 'mkdir ' + growdir
        call(cmd, shell=True)

    # store user class in users dictionary
    users[uid] = user.User()

    # reset to existing Hubway stations only
    gridpredict.resetiteration(basedir, growdir)

    # reset the results database for this user
    useraddress = []
    riderate = []
    dictnew = {"address": useraddress, "ridesperday": riderate}
    stations = pd.DataFrame(dictnew)
    stations.to_csv(growdir + 'appresults.csv', index=False)

    return render_template("input.html")
示例#3
0
import gridpredict

basedir = '../Data/Boston/'
growdir = '../Data/Boston/growing/'
gridpredict.resetiteration(basedir, growdir)
test1 = gridpredict.autoinput(growdir)
print(test1)
import pdb; pdb.set_trace()
test1 = gridpredict.autoinput(growdir)
print(test1)
import pdb; pdb.set_trace()
test1 = gridpredict.autoinput(growdir)
print(test1)
test1 = gridpredict.autoinput(growdir)
print(test1)
test1 = gridpredict.autoinput(growdir)
print(test1)
test1 = gridpredict.autoinput(growdir)
print(test1)
test1 = gridpredict.autoinput(growdir)
print(test1)

# open street map for river outline
# data thief
示例#4
0
import gridpredict

basedir = '../Data/Boston/'
growdir = '../Data/Boston/growing/'
gridpredict.resetiteration(basedir, growdir)
test1 = gridpredict.autoinput(growdir)
print(test1)
import pdb
pdb.set_trace()
test1 = gridpredict.autoinput(growdir)
print(test1)
import pdb
pdb.set_trace()
test1 = gridpredict.autoinput(growdir)
print(test1)
test1 = gridpredict.autoinput(growdir)
print(test1)
test1 = gridpredict.autoinput(growdir)
print(test1)
test1 = gridpredict.autoinput(growdir)
print(test1)
test1 = gridpredict.autoinput(growdir)
print(test1)

# open street map for river outline
# data thief