def __init__(self): self.date = dt.today() self.semester = self.get_semester() self.academic_year = self.academic_year() self.credentials = Authenticate.get_credentials() self.data = self.get_data() # Dictionary indexed by class periods. self.print_results()
def test_correct_track_found(self): authenticate = getattr(Authenticate, 'token_authentication') token = authenticate(Authenticate(), 'swttyjm9q7591l77ngrnrxqyp') search_spotify = getattr(SearchSpotify, 'search_for_track') track = search_spotify(SearchSpotify(), ('Fast Car', 'Tracy Chapman'), token) self.assertIsNotNone(track)
def __init__(self, d): self.credentials = Authenticate.get_credentials() self.file_names = self.get_file_names() # Files to process. self.date = d.date self.semester = d.semester self.academic_year = d.academic_year self.students = d.data # Dictionary indexed by periods.
def main(): songs_not_found = set() # Check arguments are passed to Convertify if len(sys.argv) > 1: if len(sys.argv) > 3: spotify_username = sys.argv[1] playlist_url = sys.argv[2] deezer_username = sys.argv[3] else: print 'Please provide your spotify username, a spotify playlist url, and ' \ 'deezer username' sys.exit() # Initialise deezer_auth = DeezerAuthenticate() authenticate = Authenticate() get_playlist_tracks = GetPlaylistTracks() search_deezer = SearchDeezer() # Get both tokens deezer_token = deezer_auth.load_token(deezer_username) spotify_token = authenticate.token_authentication(spotify_username) # Check spotify token exists if spotify_token: results = get_playlist_tracks.get_playlist(playlist_url, spotify_token) title = results['name'] spotify_tracks_and_previews = get_playlist_tracks.get_tracks( results) deezer_titles_and_previews, songs_not_found = search_deezer.search_all( spotify_tracks_and_previews) print # Check if new playlist title has been given, else use spotify title if len(sys.argv) > 5: playlist_title = sys.argv[5] else: playlist_title = title non_fingerprinting_method(deezer_titles_and_previews, songs_not_found, playlist_title, deezer_token) else: print 'Please provide your spotify username, a spotify playlist url and deezer username'
def __init__(self, df=None): self.credentials = Authenticate.get_credentials() self.date = dt.today() self.semester = self.get_semester() self.academic_year = self.get_academic_year() if df is None: self.periods = self.get_periods() self.student_data = self.get_data() else: self.student_data = df # Pandas DataFrame
def test_get_all_playlists(self): # Need to check number of playlists before running number_of_playlists = 9 authenticate = getattr(Authenticate, 'token_authentication') token = authenticate(Authenticate(), 'swttyjm9q7591l77ngrnrxqyp') get_all_playlists = getattr(GetPlaylistTracks, 'get_all_playlists') self.assertEquals( len( get_all_playlists( GetPlaylistTracks(), 'https://open.spotify.com/user/swttyjm9q7591l77ngrnrxqyp/playlist/2SChSLF3kFcy5EDwejSjKO', token)), number_of_playlists)
class Client(object): def __init__(self, OS_AUTH_URL, OS_PROJECT_NAME, OS_USERNAME, OS_PASSWORD): self.auth = Authenticate(OS_AUTH_URL, OS_PROJECT_NAME, OS_USERNAME, OS_PASSWORD) self.flavor = Flavor(self.auth.get_token_id(), self.auth.get_compute_admin_url()) self.image = Image(self.auth.get_token_id(), self.auth.get_image_admin_url()) self.heat = Heat(self.auth.get_token_id(), self.auth.get_orchestration_admin_url())
def _configure(self, config_name, action, contents): """ The main configuration for volttron central. This is where validation will occur. Note this method is called: 1. When the agent first starts (with the params from packaged agent file) 2. When 'store' is called through the volttron-ctl config command line with 'config' as the name. Required Configuration: The volttron central requires a user mapping. :param config_name: :param action: :param contents: """ config = self._default_config.copy() config.update(contents) users = config.get("users", None) if self._authenticated_sessions: self._authenticated_sessions.clear() if users is None: users = {} _log.warn("No users are available for logging in!") # Unregister all routes for vc and then re-add down below. self.vip.web.unregister_all_routes() self._authenticated_sessions = SessionHandler(Authenticate(users)) self.vip.web.register_endpoint(r'/vc/jsonrpc', self.jsonrpc) self.vip.web.register_websocket(r'/vc/ws', self.open_authenticate_ws_endpoint, self._ws_closed, self._ws_received) self.vip.web.register_path(r'^/vc/.*', config.get('webroot')) # Start scanning for new platforms connections as well as for # disconnects that happen. self._scan_platform_connect_disconnect()
def test_get_playlists(self): authenticate = getattr(Authenticate, 'token_authentication') token = authenticate(Authenticate(), 'swttyjm9q7591l77ngrnrxqyp') get_playlist = getattr(GetPlaylistTracks, 'get_playlist') self.assertIsNone( get_playlist(GetPlaylistTracks(), 'https://open.spotify.com/user', token)) self.assertIsNone(get_playlist(GetPlaylistTracks(), 123, token)) self.assertEquals( get_playlist( GetPlaylistTracks(), 'https://open.spotify.com/user/swttyjm9q7591l77ngrnrxqyp/playlist/2SChSLF3kFcy5EDwejSjKO', token)['name'], 'Test Playlist', 'Test Playlist name not returned correctly')
def test_search_for_track(self): authenticate = getattr(Authenticate, 'token_authentication') token = authenticate(Authenticate(), 'swttyjm9q7591l77ngrnrxqyp') search_spotify = getattr(SearchSpotify, 'search_for_track') track = search_spotify(SearchSpotify(), ('', ), token) self.assertIsNone(track) track_two = search_spotify(SearchSpotify(), ('Fast Car', ''), token) self.assertIsNone(track_two) track_three = search_spotify(SearchSpotify(), ('', 'Tracy Chapman'), token) self.assertIsNone(track_three) track_four = search_spotify(SearchSpotify(), ('', ''), token) self.assertIsNone(track_four) track_five = search_spotify(SearchSpotify(), ('%\\', '/%'), token) self.assertIsNone(track_five)
def startWebServer(manager): '''Starts the webserver to allow http/RpcParser calls. This is where the tornado IOLoop instance is officially started. It does block here so one should call this within a thread or process if one doesn't want it to block. One can stop the server by calling stopWebServer or by issuing an IOLoop.stop() call. ''' session_handler = SessionHandler(Authenticate(user_map)) webserver = ManagerWebApplication(session_handler, manager, hander_config, debug=True) webserver.listen(server_conf.get('port', server_conf.get('port', 8080)), server_conf.get('host', '')) tornado.ioloop.IOLoop.instance().start()
def __init__(self, user_input): self.history = self.get_history() # Past seating charts. self.update_number = self.history["Updates"][-1][ "Number"] + 1 # Calculate update number. self.time_stamp = dt.today().strftime( '%Y-%m-%d %H:%M:%S') # Time stamp for update. self.periods = self.get_periods( user_input) # Periods for which a change is requested. self.credentials = Authenticate.get_credentials() self.class_lists = self.get_class_lists() # Current class lists. self.seating_chart = self.get_seating_chart( ) # Current seating arrangements. print(self.seating_chart)
def __init__(self, d): self.credentials = Authenticate.get_credentials() self.run_setup(d)
def configure_main(self, config_name, action, contents): """ The main configuration for volttron central. This is where validation will occur. Note this method is called: 1. When the agent first starts (with the params from packaged agent file) 2. When 'store' is called through the volttron-ctl config command line with 'config' as the name. Required Configuration: The volttron central requires a user mapping. :param config_name: :param action: :param contents: """ _log.debug('Main config updated') _log.debug('ACTION IS {}'.format(action)) _log.debug('CONTENT IS {}'.format(contents)) if action == 'DELETE': # Remove the registry and keep the service running. self.runtime_config = None # Now stop the exposition of service. else: self.runtime_config = self.default_config.copy() self.runtime_config.update(contents) problems = self._validate_config_params(self.runtime_config) if len(problems) > 0: _log.error( "The following configuration problems were detected!") for p in problems: _log.error(p) sys.exit(INVALID_CONFIGURATION_CODE) else: _log.info('volttron central webroot is: {}'.format( self.runtime_config.get('webroot'))) users = self.runtime_config.get('users') self.web_sessions = SessionHandler(Authenticate(users)) _log.debug('Querying router for addresses and serverkey.') q = Query(self.core) external_addresses = q.query('addresses').get(timeout=5) self.runtime_config['local_external_address'] = external_addresses[ 0] self.vip.web.register_websocket(r'/vc/ws', self.open_authenticate_ws_endpoint, self._ws_closed, self._ws_received) self.vip.web.register_endpoint(r'/jsonrpc', self.jsonrpc) self.vip.web.register_path(r'^/.*', self.runtime_config.get('webroot')) # Start scanning for new platforms connections as well as for # disconnects that happen. self._scan_for_platforms()
def search_for_mvn(self, repo, username, password): start = "https://api.github.com/search/code?q=project+" filename = "filename:.xml+pom" repo_search = "+repo:"+repo search_string = start + filename + repo_search while True: print 'DEBUG: requesting', search_string temp = requests.get(search_string, auth=(username, password)) #print 'status code', temp.status_code if temp.status_code == ACCEPTED_STATUS_CODE: return temp.json() else: print "DEBUG sleep:", SLEEP_TIME, "seconds" time.sleep(SLEEP_TIME) continue ############################################################################### test = Authenticate() username, password = test.doAuthenticate() ## testing things #code_search_dico = searchRepoForJunitTests("Rory1994/WAW-Assessment4", "java") findProjects = FindProjects() temp_repo = findProjects.search_github("", 10000, 0, "java", "forks", "desc", 6, username, password) for i in temp_repo: print "Name:", i.name, i.url #RunMutationTools(i, CLONED_REPOS_PATH).setup_repo() #a.run_jumble(i, "C:\Users\Megan\Documents\clonedRepos") #print "temp", temp_repo
def __init__(self, config_path, **kwargs): """ Creates a `VolttronCentralAgent` object to manage instances. Each instances that is registered must contain a running `VolttronCentralPlatform`. Through this conduit the `VolttronCentralAgent` is able to communicate securly and efficiently. :param config_path: :param kwargs: :return: """ _log.info("{} constructing...".format(self.__name__)) # This is a special object so only use it's identity. identity = kwargs.pop("identity", None) identity = VOLTTRON_CENTRAL super(VolttronCentralAgent, self).__init__(identity=identity, **kwargs) # Load the configuration into a dictionary self._config = utils.load_config(config_path) # Expose the webroot property to be customized through the config # file. self._webroot = self._config.get('webroot', DEFAULT_WEB_ROOT) if self._webroot.endswith('/'): self._webroot = self._webroot[:-1] _log.debug('The webroot is {}'.format(self._webroot)) # Required users self._user_map = self._config.get('users', None) _log.debug("User map is: {}".format(self._user_map)) if self._user_map is None: raise ValueError('users not specified within the config file.') # Search and replace for topics # The difference between the list and the map is that the list # specifies the search and replaces that should be done on all of the # incoming topics. Once all of the search and replaces are done then # the mapping from the original to the final is stored in the map. self._topic_replace_list = self._config.get('topic_replace_list', []) self._topic_replace_map = defaultdict(str) _log.debug('Topic replace list: {}'.format(self._topic_replace_list)) # A resource directory that contains everything that can be looked up. self._resources = ResourceDirectory() self._registry = self._resources.platform_registry # This has a dictionary mapping the platform_uuid to an agent # connected to the vip-address of the registered platform. If the # registered platform is None then that means we were unable to # connect to the platform the last time it was tried. self._pa_agents = {} # if there is a volttron central agent on this instance then this # will be resolved. self._peer_platform = None # An object that allows the checking of currently authenticated # sessions. self._sessions = SessionHandler(Authenticate(self._user_map)) self.webaddress = None self._web_info = None # A flag that tels us that we are in the process of updating already. # This will allow us to not have multiple periodic calls at the same # time which could cause unpredicatable results. self._flag_updating_deviceregistry = False self._setting_store = load_create_store( os.path.join(os.environ['VOLTTRON_HOME'], 'data', 'volttron.central.settings')) self._request_store = load_create_store( os.path.join(os.environ['VOLTTRON_HOME'], 'data', 'volttron.central.requeststore'))