def WaitQueueWakeHandler(event): if Global.IsUserInSystemUI(): return if Global.isWebViewThread(event.pid): FindConnectorAndUpdate(event, wait_queue_notify_key_func) else: DefaultHandler(event)
def WaitQueueWaitHandler(event): if Global.IsUserInSystemUI(): return if Global.isWebViewThread(event.pid): MarkCurrentWorkingUnitEnded(event.pid) else: DefaultHandler(event)
def ContextSwitchHandler(event): if Global.IsUserInSystemUI(): return if Global.isWebViewThread(event.data['old']) and Global.ThreadState(event.data['old']) != 'R': MarkCurrentWorkingUnitEnded(event.data['old']) else: DefaultHandler(event)
def WaitQueueNotifyHandler(event): if Global.IsUserInSystemUI(): return if Global.isWebViewThread(event.data['pid']): key = DefaultHandlerInternal(event) AddConnector(event, wait_queue_notify_key_func, key) # insert a FAKED_WAITQUEUE_WAKE event in the notified thread thread_state = Global.ThreadState(event.data['pid']) if (key is not None) and (thread_state == 'I' or thread_state == 'U'): new_event = copy.deepcopy(event) new_event.event = 'FAKED_WAITQUEUE_WAKE' new_event.pid = event.data['pid'] del new_event.data['pid'] new_event.json['event'] = new_event.event new_event.json['pid'] = new_event.pid new_key = Global.AddNode(new_event) threads = Global.ActiveThreads() threads[new_event.pid] = new_key Global.AddEdge(key, new_key)
def __init__(self, DEBUG=False): """Constructor""" if DEBUG: print('Running Main...') # Message object. self.message_obj = Message(input_info=input_info, n_frames=n_frames) # Mapping object. self.mapping_obj = Mapping(bitstream_frames=bitstream_frames, mapping_type=mapping_type, bits_per_symbol=bits_per_symbol) # Modulator object. self.modulator_obj = Modulator(mapped_info=mapped_info, modulation_type=modulation_type) # Transmitter object. self.transmitter_obj = Transmitter( transmitter_config=transmitter_config, tx_data=tx_data, bypass=bypass) # Channel object self.channel_obj = Channel(tx_data_in=tx_data_in, raytrace=raytrace) # Receiver object. self.receiver_obj = Receiver(receiver_config=receiver_config, rx_data=rx_data, bypass=bypass) # Merit Funcions object self.merit_functions_obj = MeritFunctions() # Global object. self.global_obj = Global() pass
def UIUpdateV2Handler(event): if Global.IsUserInSystemUI(): return ctors = Global.Connectors() threads = Global.ActiveThreads() event.thread_name = Global.ThreadName(event.pid) # find the connector ctor_key = ui_invalidate_key_func(event) if ctor_key in ctors: # connects all previous events to the current event key = Global.AddNode(event) for n in ctors[ctor_key]: Global.AddEdge(n, key) del ctors[ctor_key] # decouple the previous event with the current event in the same thread threads[event.pid] = key
def WaitQueueNotifyHandler(event): if Global.IsUserInSystemUI(): return if Global.isWebViewThread(event.data['pid']): key = DefaultHandlerInternal(event) AddConnector(event, wait_queue_notify_key_func, key) # insert a FAKED_WAITQUEUE_WAKE event in the notified thread thread_state = Global.ThreadState(event.data['pid']) if (key is not None) and (thread_state == 'I' or thread_state == 'U'): new_event = copy.deepcopy(event) new_event.event = 'FAKED_WAITQUEUE_WAKE' new_event.pid = event.data['pid'] del new_event.data['pid'] new_event.json['event'] = new_event.event new_event.json['pid'] = new_event.pid new_key = Global.AddNode(new_event) threads = Global.ActiveThreads() threads[new_event.pid] = new_key Global.AddEdge(key, new_key)
def PrintTrans(user_dir): Global.LoadThreadNameMap(user_dir + 'thread_name_map') for trans_file in glob.glob(user_dir + 'transactions/UI_INPUT*'): print('-------' + trans_file + '---------') g = LoadGraph(trans_file) print(TransToString(g))
def BinderReplyHandler(event): if Global.IsUserInSystemUI(): return BinderProduceHandlerInternal(event) MarkCurrentWorkingUnitEnded(event.pid)
def MarkCurrentWorkingUnitEnded(thread_id): threads = Global.ActiveThreads() if thread_id in threads: del threads[thread_id]
import requests import json import csv from Player import Player from Niveau import Niveau from Global import Global app = Flask(__name__, static_url_path='/', static_folder='web/static', template_folder='web/templates') level = Niveau(1) player = Player(level) g = Global(player, level) #Page d'accueil @app.route('/') def mainpage(): return render_template('index.html') # Cherche si le joueur a déjà joué @app.route('/', methods=["POST"]) def player_infos(): nom = request.form["nom"] response = make_response(redirect(url_for('jeu'))) response.set_cookie('nom', nom)
def EnqueueMessageHandler(event): if Global.IsUserInSystemUI(): return key = DefaultHandlerInternal(event) # insert a connector AddConnector(event, msg_key_func, key)
def PollDoneHandler(event): if Global.IsUserInSystemUI(): return MarkCurrentWorkingUnitEnded(event.pid)
def AddConnector(event, connector_key_func, key): if key is None: return ctors = Global.Connectors() ctor_key = connector_key_func(event) ctors[ctor_key] = key
def __init__(self, LogObj, ProjObj): self.__LogObj = LogObj self.__ProjObj = ProjObj self.__InstanceID = Global.CreateGUID()
def UIUpdateHandler(event): if Global.IsUserInSystemUI(): return FindConnectorAndUpdate(event, ui_invalidate_key_func)
def UIInvalidateHandler(event): if Global.IsUserInSystemUI(): return key = DefaultHandlerInternal(event) # insert a connector AddConnector(event, ui_invalidate_key_func, key)
def DVFSConfigChangeHandler(event): Global.NotifyDvfsConfigChange(event.data['old'], event.data['new'])
def CoreConfigChangeHandler(event): Global.NotifyCoreConfigChange(event.data['old'], event.data['new'])
def DequeueMessageHandler(event): if Global.IsUserInSystemUI(): return FindConnectorAndUpdate(event, msg_key_func)
def collect_products_urls(self, description, product_category): products_url = [] url = Global.base_url( ) + product_category + "?pageView=grid&orderBy=5&fromPage=catalogEntryList&beginIndex=0" headers = {"User-Agent": Global.url_headers()} response = requests.get(url, headers=headers) html_soup = BeautifulSoup(response.text, 'html.parser') pages = html_soup.find_all('a', attrs={'data-page-number': True}) # Check if pages is empty. If so, there's less then one page of data to process, and handle accordingly if not pages: last_page_amount = 1 else: last_page_amount = int(pages.pop().text) # Get initial page content Global.write_to_log_file(description + ".log", "Starting Page 0 of " + product_category) beverages = html_soup.find_all('div', class_='row product') for beverage in beverages: name = beverage.find('div', class_='product_name') products_url.append(name.a['href']) Global.write_to_log_file(description + ".log", "Ending Page 0 of " + product_category) # Now time to loop through the rest of the pages for pageValue in range(1, last_page_amount): Global.write_to_log_file( description + ".log", "Starting Page " + str(pageValue) + " of " + product_category) begin_index = pageValue * 12 url = Global.base_url( ) + product_category + "?pageView=grid&orderBy=5&fromPage=catalogEntryList&beginIndex=" + str( begin_index) headers = {"User-Agent": Global.url_headers()} response = requests.get(url, headers=headers) html_soup = BeautifulSoup(response.text, 'html.parser') beverages = html_soup.find_all('div', class_='row product') for beverage in beverages: name = beverage.find('div', class_='product_name') products_url.append(name.a['href']) Global.write_to_log_file( description + ".log", "Ending Page " + str(pageValue) + " of " + product_category) return products_url
def FutexNotifyHandler(event): if Global.IsUserInSystemUI(): return if Global.isWebViewThread(event.data['pid']): key = DefaultHandlerInternal(event) AddConnector(event, futex_notify_key_func, key)
from flask import Flask, abort, render_template, send_from_directory, redirect from threading import Thread import logging import asyncio import json from DiscordClient import DiscordClient from Global import Global, Constant from History import GlobalHistory from Leaders import load_leaders logging.basicConfig(level="INFO") load_leaders() Global.load() app = Flask(__name__) SIDEBAR_KWARGS = { 'mapuches': Global.mapuches, 'didons': Global.didons, 'christines': Global.christines } async def cron(): while True: await asyncio.sleep(3600) Global.reload()
def AsyncTaskSubmitHandler(event): if Global.IsUserInSystemUI(): return key = DefaultHandlerInternal(event) # insert a connector AddConnector(event, async_task_key_func, key)
from sklearn.model_selection import train_test_split from sklearn import metrics from sklearn.model_selection import GridSearchCV import pickle from joblib import dump, load ##################################################################################### #Initial variables ##################################################################################### vectorizer = TfidfVectorizer(stop_words='english') shuffle = True remove = ['footers', 'quotes'] const = Global() def import_json_to_Dataframe(path, filename): path = path + '\\' + filename df = pd.read_json(path, lines=True) print('Dataframe imported from ' + path) return df def export_Dataframe_to_csv(df, path, filename): path = path + '\\' + filename df.to_csv(path, index=False) #print('Dataframe exported to ' + path) return 0
def calculateWayPointsVisited(self, agent): for wayPoint in self.wayPoints: if self.DistanceObjs(wayPoint, agent) < Global.WayPointArea: wayPoint.lastVisited = Global.GetSeconds()
def AsyncTaskConsumeHandler(event): if Global.IsUserInSystemUI(): return FindConnectorAndUpdate(event, async_task_key_func)
def old_main(filename): global gState g = LoadGraph(filename) paths = CriticalPaths(g) for input_n in paths.keys(): #PrintInputPaths(input_n, paths[input_n], filename, g, gState) print('---------'+ input_n + '--------------') update_paths = paths[input_n] for path_to_update in update_paths: path = path_to_update['path'] print(PathToString(path)) for evt in path: CountHandlerMap[evt.event](evt, gState) print(PathProfile(path[0], path[-1], gProfile)) ClearProfile(gProfile) if __name__=='__main__': if len(sys.argv) < 3: print('Usage: python ResourceCounting.py < mode: 1: single file; 2: all files in a folder> < path to transaction file or all files in a folder>') sys.exit(0) else: if int(sys.argv[1]) == 1: # print individual transaction if len(sys.argv) >= 4: Global.LoadThreadNameMap(sys.argv[3]) old_main(sys.argv[2]) else: new_main(sys.argv[2])
def ThreadNameHandler(event): # TODO: temporary hack to guess reboot event if event.data['pid'] == 7: Global.ScheduleWriteGraph(synchronous=False) Global.ResetAll() Global.AddThreadName(event.data['pid'], event.data['name'])
async def cron(): while True: await asyncio.sleep(3600) Global.reload()
def FutexNotifyHandler(event): if Global.IsUserInSystemUI(): return if Global.isWebViewThread(event.data['pid']): key = DefaultHandlerInternal(event) AddConnector(event, futex_notify_key_func, key)
class Application: # First check if a category has been passed by the command line to process. If not, close. if len(sys.argv) > 1: category = sys.argv[1] else: print("An argument is needed. Specify a category.") sys.exit(1) psps = ProductsPageScraper() pps = ProductPageScraper() pips = ProductInventoryPageScraper() # Sets data directory that we'll save everything too. Avoids script failure when script is run past midnight Global.set_current_date() # Get category contents. We do this so we can split the load across multiple shell instances. If input is invalid, # close and log an error product_dict_data = Global.product_dict_data(category) if product_dict_data == "Invalid month": print("Category " + category + " not found. Exiting") # Directory doesn't exist. Comment out code for now. #Global.write_to_log_file("main.log", "Category " + category + " not found. Exiting") sys.exit(1) # Loop through all products of specified family for description, product_category in product_dict_data.items(): # Create data directory Global.create_data_directory(description) # Get start time start_time = datetime.now() Global.write_to_log_file( description + ".log", "Product and Inventory data for " + description + " started @ " + start_time.strftime("%d/%m/%Y %H:%M:%S")) # Get URLs for all product in category product_urls = psps.collect_products_urls(description, product_category) # Gets product data for specific item for idx, product_url in enumerate(product_urls, start=1): product_id = pps.get_product_data(product_url) pps.write_to_file("product.csv", idx) # Put this code in as we're getting errors that product_id is None if product_id: pips.get_product_inventory_data(product_id) pips.write_to_file("inventory.csv", idx) else: Global.write_to_log_file( "error.log", "Product ID " + str(product_id) + " is None for " + product_url) Global.write_to_log_file( description + ".log", "Inventory and data for product " + str(idx) + " processed") # Get end time end_time = datetime.now() Global.write_to_log_file( description + ".log", "Product and Inventory data for " + description + " complete @ " + end_time.strftime("%d/%m/%Y %H:%M:%S")) # We'll need this or else you'll have zombie processes sys.exit(0)
def BinderOneWayProduceHandler(event): if Global.IsUserInSystemUI(): return BinderProduceHandlerInternal(event)
def SaveHeatMap(self): for obj in self.objects: objStr = str(obj.x) + ";" + str( obj.y) + ";%.4f" % (obj.trainHistory) Global.LogData("objheatmap", objStr)
for line in sys.stdin: event = Event.decode_event(line) if current_time != event.timestamp: ReorderAndHandleEvents(event_list) del event_list event_list = [] event_list.append(event) current_time = event.timestamp if Global.Graph().number_of_nodes() > 1000000: Global.PrintMemoryUsage() Global.TryCleanupGraph(event.timestamp) Global.PrintMemoryUsage() sys.stderr.flush() sys.stdout.flush() ReorderAndHandleEvents(event_list) del event_list def old_main(): for line in sys.stdin: event = Event.decode_event(line) # Common handling Global.UpdateThreadState(event) # Event-specific handling event_handler_map[event.event](event) if __name__ == '__main__': new_main() Global.ScheduleWriteGraph()