def startPlaylist(tracks, defaultPosition = 0): if defaultPosition != None and is_valid_num(0, len(tracks) - 1, defaultPosition): data = playlistThreader.getThread(tracks, defaultPosition) else: data = playlistThreader.getThread(tracks) if len(tracks) == 0: return send_error(error_codes.NO_PATH_DEFINED, "No track parameter passed.") errorPos = [] for index, trackPath in enumerate(tracks): if not os.path.exists(trackPath) or not check_path(trackPath): errorPos.append({"index" : index}) errorPos[-1].update(send_error(error_codes.WRONG_PATH_SPECIFIED, "File doesn't exsist.", False)) continue if not is_valid_file(trackPath): errorPos.append({"index" : index}) errorPos[-1].update(send_error(error_codes.INVALID_TYPE, "Invalid filetype.", False)) continue if len(errorPos) > 0: return send_playlist_play_error(errorPos, "Invalid track array") flushTrack() currentPlaylist = data.get('playlist') playlistThreader.startThread() return send_state_playlist_message(currentPlaylist, "Playlist succesfully started", None, 1, False)
def startTrack(trackPath): #trackThreader.registerOnEndCustomCallback(track_endevent) if(trackPath == "" or trackPath == None): return send_error(error_codes.NO_PATH_DEFINED, "No path parameter passed.") if not os.path.exists(trackPath) or not check_path(trackPath): return send_error(error_codes.WRONG_PATH_SPECIFIED, "File doesn't exsist.") if not is_valid_file(trackPath): return send_error(error_codes.INVALID_TYPE, "Invalid filetype.") flushPlaylist() data = trackThreader.getThread(trackPath) currentThread = data.get('thread') currentTrack = data.get('track') currentThread.start() return send_state_track_message(currentTrack, "Track started")
from helpers import read_reviews from helpers import is_valid_file import argparse import os import csv import io argparser = argparse.ArgumentParser() argparser.add_argument("-asins", dest="filename", required=True, help="Enter the path to your ASIN file.", type=lambda x: is_valid_file(argparser, x)) args = argparser.parse_args() inputFile = args.filename print(inputFile) # check for current os if os.name == 'posix': # osx driver_path = '/usr/local/bin/chromedriver' elif os.name == 'nt': # win32 driver_path = 'C:\chromedriver\chromedriver' else: print('Unknown operating system!!!') exit() data = read_reviews(driver_path, inputFile)