<s> import os <EOL> from config import basedir <EOL> from refinery import app , db <EOL> from refinery . data . models import * <EOL> import shutil <EOL> def create_db_entries ( ) : <EOL> print "<STR_LIT>" <EOL> userdir = app . config [ '<STR_LIT>' ] <EOL> try : <EOL> os . stat ( userdir ) <EOL> except : <EOL> os . mkdir ( userdir ) <EOL> remove_dir ( userdir ) <EOL> db . drop_all ( ) <EOL> db . create_all ( ) <EOL> usernames = [ '<STR_LIT>' ] <EOL> passwords = [ '<STR_LIT>' ] <EOL> for i in xrange ( len ( usernames ) ) : <EOL> add_user ( usernames [ i ] , passwords [ i ] ) <EOL> check_db ( ) <EOL> def check_db ( ) : <EOL> query_users = User . query . all ( ) <EOL> query_exp = Experiment . query . all ( ) <EOL> query_data = Dataset . query . all ( ) <EOL> def remove_dir ( folder ) : <EOL> for the_file in os . listdir ( folder ) : <EOL> file_path = os . path . join ( folder , the_file ) <EOL> if os . path . isdir ( file_path ) : <EOL> print "<STR_LIT>" + file_path <EOL> shutil . rmtree ( file_path ) <EOL> def create_user_dir ( username ) : <EOL> newdir = app . config [ '<STR_LIT>' ] + username <EOL> if os . path . exists ( newdir ) : <EOL> print "<STR_LIT>" + username <EOL> else : <EOL> datadir = newdir + "<STR_LIT>" <EOL> imdir = newdir + "<STR_LIT>" <EOL> procdir = newdir + "<STR_LIT>" <EOL> os . makedirs ( newdir ) <EOL> os . makedirs ( procdir ) <EOL> os . makedirs ( datadir ) <EOL> os . makedirs ( imdir ) <EOL> print "<STR_LIT>" + newdir <EOL> def add_user ( username , password ) : <EOL> '''<STR_LIT>''' <EOL> create_user_dir ( username ) <EOL> email = username + "<STR_LIT>" <EOL> u = User ( username = username , password = password , email = email ) <EOL> if ( username == "<STR_LIT>" ) : <EOL> u . email = "<STR_LIT>" <EOL> shutil . copyfile ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> u . image = "<STR_LIT>" <EOL> db . session . add ( u ) <EOL> db . session . commit ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> create_db_entries ( ) </s>
