def set_up_local_db(user): ''' sets up local sqllite db, and adds the songs table ''' local_path = get_db_path('local') local_db = db_wrapper(local_path) local_db.create_songs_table()
print('Use format read_tunes.py [(ignore, update)] [user](default is current)') sys.exit(0) else: update_main = True if sys.argv[1] == 'update' else False #end ugliness ######################################################### parser = xml.sax.make_parser() handler = ITunesHandler() parser.setContentHandler(handler) path = settings.get('itunes_data', 'path') #path = settings.get('itunes_data', 'path_test') TEST file_location = "/Users/%s/%s" % (user, path) #file_location = "/Users/%s/%s" % ('cwood', path) TEST db_path = get_db_path('central') central_db = db_wrapper(db_path) local_db_dir = settings.get('db_settings', 'local_db_dir') #Is this a new user in the central db? Wipe out any existing local db if so if not user_exists(user): #--------------------First Time User-------------------- confirm = raw_input('''**************************************************** The directory %s is about to be created, if it already exists it will be destroyed. Keep going? (y/n)''' % (local_db_dir)) if confirm[0].lower() == 'y': central_db.add_user(user) set_up_dir(user) set_up_local_db(user) else: raise_error('abort', '\nSidus user creation has been cancelled.\n')
def user_exists(username): ''' just a boolean yay or nay for whether a user already exists ''' db = db_wrapper(get_db_path('central')) return(not (db.get_user(username) == None))