def GetSettings(): try: print( f'cascade: {request.form["cascade"]};\nport: {request.form["port"]};\nscaleFactor: {request.form["scaleFactor"]};\nminNeighbors: {request.form["minNeighbors"]};\narea: {request.form["area"]};\nkey: {request.form["key"]}' ) if (request.form["key"] != Settings.key): return jsonify({"response": 900}) Settings.SetSetting(Settings, float(request.form["scaleFactor"]), int(request.form["minNeighbors"]), int(request.form["area"]), 0, request.form["cascade"], request.form["port"]) asyncio.run(main.Start()) except Exception as e: print(e) return jsonify({"response": 500}) return jsonify({"response": 200})
__author__ = 'naetech' import os import module_locator from Classes.Settings import Settings from Classes.PHP import PHP from Classes.GUI import GUI program_path = module_locator.module_path() print("Program path is: %s" % program_path) program_settings = Settings() settings_file_path = "%s/%s" % (program_path, "settings.ini") program_settings.load_settings(settings_file_path) php_path = str(program_settings.read_setting("php_path")) if not os.path.exists(php_path): # perhaps we should try something relative php_path = "%s/%s" % (program_path, php_path) port = str(program_settings.read_setting("port")) webroot = str(program_settings.read_setting("webroot")) if not os.path.exists(webroot): # perhaps we should try something relative
from Classes.Compiler import Compiler from Classes.Settings import Settings import sys import locale locale.setlocale(locale.LC_ALL, 'de_DE') settings = Settings() compiler = Compiler("./dist", "./nrtmp", "./Resources", sys.argv[1:]) # clean output folder compiler.clean_dist() # compile nightrain if compiler.is_windows(): compiler.compile_nightrain_windows() if compiler.is_linux(): compiler.compile_nightrain_linux() if compiler.is_mac(): compiler.compile_nightrain_mac() # compile PHP if compiler.is_windows(): compiler.compile_php_windows() if compiler.is_linux(): compiler.compile_php_linux()
def on_btn_settings(self): self.work = False win_settings = Settings(background=self.background) win_settings.run()
__author__ = 'naetech' import os import module_locator program_path = module_locator.module_path() print "Program path is: %s" % program_path from Classes.Settings import Settings from Classes.PHP import PHP from Classes.GUI import GUI program_settings = Settings() settings_file_path = "%s/%s" % (program_path, "settings.ini") program_settings.load_settings(settings_file_path) php_path = str(program_settings.read_setting("php_path")) if not os.path.exists(php_path): # perhaps we should try something relative php_path = "%s/%s" % (program_path, php_path) port = str(program_settings.read_setting("port")) webroot = str(program_settings.read_setting("webroot")) if not os.path.exists(webroot): # perhaps we should try something relative
from Classes.Compiler import Compiler from Classes.Settings import Settings settings = Settings() compiler = Compiler("./dist", "./nrtmp", "./Resources") # clean output folder compiler.clean_dist() # compile nightrain if compiler.is_windows(): compiler.compile_nightrain_windows() if compiler.is_linux(): compiler.compile_nightrain_linux() if compiler.is_mac(): compiler.compile_nightrain_mac() # compile PHP if compiler.is_windows(): compiler.compile_php_windows() if compiler.is_linux(): compiler.compile_php_linux() if compiler.is_mac(): compiler.compile_php_mac()
class GameLibrary(object): def __init__(self): self.library = [] self.settings = Settings() self.settings.load_from_folder() self.populate() # adds a game object to library def add_game(self, game): self.library.append(game) # installs a game by name or returns a list of installers if there are multiple def install_game(self, game_name): for game in self.library: if game.title == game_name: # Install that shit. if len(game.installers) == 0: temp_text = "There is no recognized installer type for this game. \n" temp_text += "Do you wish to open the game folder to search for in installer manually?" answer = tkinter.messagebox.askquestion( 'Open game folder?', temp_text) if answer == 'yes': startfile(game.directory) return 0 elif len(game.installers) == 1: launch_installer(game.installers[0]) return 0 else: return game.installers # returns a library as a list of lists def as_list(self): lst = [] for i in self.library: lst.append(i.as_list()) return lst # populates a library from a directory, ignores '!' dirs and stuff. # distrib_source for the whole dir. If several sources, input 0 def populate_from_dir(self, directory, distrib_source): for entry in scandir(directory): if (entry.name[0] != "!") and (entry.name != "System Volume Information") and entry.is_dir(): # titles will include [ and ] for distrib_source, we ignore them for title and parse them for source if entry.name.find('[') >= 0: game_title = entry.name[0:entry.name.find('[')].strip() else: game_title = entry.name folder = entry.path version = 0.0 # for installers we use a function installer = get_installer_paths(folder) if distrib_source != 0: distrib_type = distrib_source elif entry.name.find('[') >= 0: distrib_type = entry.name[entry.name.find('[') + 1:entry.name.find(']')].strip() else: distrib_type = "Unknown" new_game = Game(game_title, version, folder, installer, distrib_type) self.add_game(new_game) # populates from all directories in the settings, key = path, value = distrib_source def populate(self): path_dir = self.settings.dict_by_name('Paths') for key in path_dir: self.populate_from_dir(key, path_dir[key]) # finds duplicate games by title. Returns a number of duplicates. Displays message box with results def find_duplicates(self): number_of_duplicates = 0 temp = [] lst_to_populate = [] for idx, val in enumerate(self.library): if val.title not in temp: temp.append(val.title) else: # Duplicate found number_of_duplicates += 1 lst_to_populate.append(val.title) # display results if number_of_duplicates == 0: tkinter.messagebox.showinfo( 'Results', "No duplicates found in your library!") else: temp_text = 'Found %d duplicates in your base:\n' % number_of_duplicates for i in lst_to_populate: temp_text += i + '\n' tkinter.messagebox.showinfo('Results', temp_text) return number_of_duplicates # finds a game/games in library. Returns a subset of game library as a game library def find_games_by_name(self, game_name): subset = GameLibrary() subset.library = [] game_name = game_name.lower() for game in self.library: temp = game.title.lower() if temp.find(game_name) != -1: # seems like a match subset.add_game(game) return subset
def __init__(self): self.library = [] self.settings = Settings() self.settings.load_from_folder() self.populate()