def run(screen_name): window = Gtk.Window() window.connect('destroy', Gtk.main_quit) #window.set_size_request(600, 500) window.set_border_width(12) window.set_title("Cnchi - Test of %s screen" % screen_name) import config settings = config.Settings() settings.set('data', '/usr/share/cnchi/data') from desktop_environments import DESKTOPS settings.set('desktops', DESKTOPS) settings.set('language_code', 'ca') params = {} params['title'] = "Cnchi" params['ui_dir'] = "/usr/share/cnchi/ui" params['disable_tryit'] = False params['settings'] = settings params['forward_button'] = Gtk.Button.new() params['backwards_button'] = Gtk.Button.new() params['main_progressbar'] = Gtk.ProgressBar.new() params['header'] = Gtk.HeaderBar.new() params['testing'] = True params['callback_queue'] = None params['alternate_package_list'] = "" screen = get_screen(screen_name, params) if screen != None: screen.prepare('forward') window.add(screen) window.show_all() Gtk.main() else: print("Unknown screen")
def run(screen_name): """ Run screen to be able to test it """ window = Gtk.Window() window.connect('destroy', Gtk.main_quit) # window.set_size_request(600, 500) window.set_border_width(0) window.set_title("Cnchi - Test of {0} screen".format(screen_name)) import logging logger = logging.getLogger() logger.setLevel(logging.DEBUG) stream_handler = logging.StreamHandler() stream_handler.setLevel(logging.DEBUG) formatter = logging.Formatter( '[%(asctime)s] [%(module)s] %(levelname)s: %(message)s', "%Y-%m-%d %H:%M:%S") stream_handler.setFormatter(formatter) logger.addHandler(stream_handler) import config settings = config.Settings() settings.set('data', '/usr/share/cnchi/data') from desktop_info import DESKTOPS settings.set('desktops', DESKTOPS) settings.set('language_code', 'ca') params = { 'title': "Cnchi", 'main_window': window, 'UI_DIR': "/usr/share/cnchi/ui", 'disable_tryit': False, 'settings': settings, 'forward_button': Gtk.Button.new(), 'backwards_button': Gtk.Button.new(), 'main_progressbar': Gtk.ProgressBar.new(), 'header': Gtk.HeaderBar.new(), 'callback_queue': None, 'alternate_package_list': "", 'process_list': [] } screen = get_screen(screen_name, params) if screen is not None: window.add(screen) window.show_all() screen.prepare('forward') Gtk.main() else: print("Unknown screen")
async def recognize_with_baidu(predict_plate, file, mask): headers = { 'user-agent': "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36" } # get token host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id={}&client_secret={}'.format( config.Settings().client_id, config.Settings().client_secret) res = requests.get(host, headers=headers).text token = json.loads(res)['access_token'] # recognize url = "https://aip.baidubce.com/rest/2.0/ocr/v1/license_plate?access_token=" + token image = base64.b64encode(file) respond = requests.post(url, data={ 'image': image, 'multi_detect': 'false' }, headers=headers) respond.encoding = 'utf-8' words_result = json.loads(respond.text) if 'words_result' not in words_result.keys(): print('%s未识别') return baidu_result = words_result['words_result']['number'] if predict_plate == baidu_result: print('识别结果一致') return print('识别结果不一致,百度识别结果:{}'.format(baidu_result)) img = tf.image.decode_jpeg(file, channels=3) img = tf.image.resize(img, [416, 416]) img = np.asarray(img) plate_image = locate(img, mask) file_path = './dataset/error/' + time.strftime( "%Y_%m_%d_%H", time.localtime()) + '/' + baidu_result + '/plate.jpeg' tf.io.write_file(file_path, tf.image.encode_jpeg(plate_image))
def step(CurrentGame): last_update_time = CurrentGame.GameState().last_update_time current_time = time.time() passed_time = 0 if last_update_time is not None: passed_time = current_time - last_update_time nn_time = config.Settings().settings["update_time"] remain_time = nn_time - passed_time time.sleep(remain_time) CurrentGame.update() CurrentGame.GameState().last_update_time = time.time()
def setUp(self): '''Create a database and modify it''' self.settings = config.Settings() self.database_path = self.settings.render_database_file self.default_id = [ 1, "comp-001", "Available", "None", "None", "None", "None", "None" ] self.header = [ "id", "client", "status", "host", "ifd", "start_time", "progress", "pids" ] self.valid_status = ["Available", "Disabled", "Rendering"]
def __init__(self, file_path): '''Initialize the file object''' self.settings = config.Settings() self.render_file = file_path self.directory = self.get_directory(self.render_file) self.ifd_user = self.get_ifd_user(self.directory) self.basename = self.get_basename(self.render_file) self.compression = self.get_compression(self.basename) self.extension = self.get_extension(self.basename) self.filename = self.get_filename(self.basename) self.seq_obj = self.get_seq_object(self.directory, self.basename) self.seq_files = [obj.name for obj in self.seq_obj] self.is_seq = self.determine_if_seq(self.seq_obj) self.filename_head = self.get_filename_head(self.is_seq, self.seq_obj) self.filename_tail = self.get_filename_tail(self.is_seq, self.seq_obj) self.seq_length = self.seq_obj.length() self.seq_frames = self.get_seq_frames(self.is_seq, self.seq_obj) self.start_frame = self.get_start_frame(self.is_seq, self.seq_obj) self.end_frame = self.get_end_frame(self.is_seq, self.seq_obj) self.seq_padding = self.get_padding(self.is_seq, self.seq_obj)
from operation import Operation import pymclevel from pymclevel.box import Vector from renderer import PreviewRenderer from select import SelectionOperation from pymclevel.pocket import PocketWorld from pymclevel import block_copy, BoundingBox import logging log = logging.getLogger(__name__) import config CloneSettings = config.Settings("Clone") CloneSettings.copyAir = CloneSettings("Copy Air", True) CloneSettings.copyWater = CloneSettings("Copy Water", True) CloneSettings.copyBiomes = CloneSettings("Copy Biomes", True) CloneSettings.staticCommands = CloneSettings("Change Coordinates", False) CloneSettings.placeImmediately = CloneSettings("Place Immediately", True) class CoordsInput(Widget): is_gl_container = True def __init__(self): Widget.__init__(self) self.nudgeButton = NudgeButton() self.nudgeButton.nudge = self._nudge
def __init__(self, app, cmd_line): Gtk.ApplicationWindow.__init__(self, title="Cnchi", application=app) self._main_window_width = 875 self._main_window_height = 550 logging.info("Cnchi installer version %s", info.CNCHI_VERSION) self.settings = config.Settings() self.ui_dir = self.settings.get('ui') if not os.path.exists(self.ui_dir): cnchi_dir = os.path.join(os.path.dirname(__file__), './') self.settings.set('cnchi', cnchi_dir) ui_dir = os.path.join(os.path.dirname(__file__), 'ui/') self.settings.set('ui', ui_dir) data_dir = os.path.join(os.path.dirname(__file__), 'data/') self.settings.set('data', data_dir) self.ui_dir = self.settings.get('ui') # By default, always try to use local /var/cache/pacman/pkg xz_cache = ["/var/cache/pacman/pkg"] # Check command line if cmd_line.cache and cmd_line.cache not in xz_cache: xz_cache.append(cmd_line.cache) # Log cache dirs for xz in xz_cache: logging.debug( "Cnchi will use '%s' as a source for cached xz packages", xz) # Store cache dirs in config self.settings.set('xz_cache', xz_cache) data_dir = self.settings.get('data') # For things we are not ready for users to test self.settings.set('z_hidden', cmd_line.z_hidden) # Set enabled desktops if self.settings.get('z_hidden'): self.settings.set("desktops", desktop_info.DESKTOPS_DEV) else: self.settings.set("desktops", desktop_info.DESKTOPS) if cmd_line.environment: my_desktop = cmd_line.environment.lower() if my_desktop in desktop_info.DESKTOPS: self.settings.set('desktop', my_desktop) self.settings.set('desktop_ask', False) logging.debug( "Cnchi will install the %s desktop environment", my_desktop) self.ui = Gtk.Builder() path = os.path.join(self.ui_dir, "cnchi.ui") self.ui.add_from_file(path) self.add(self.ui.get_object("main")) self.header_ui = Gtk.Builder() path = os.path.join(self.ui_dir, "header.ui") self.header_ui.add_from_file(path) self.header = self.header_ui.get_object("header") self.logo = self.header_ui.get_object("logo") path = os.path.join( data_dir, "images", "antergos", "antergos-logo-mini2.png") self.logo.set_from_file(path) # To honor our css self.header.set_name("header") self.logo.set_name("logo") self.main_box = self.ui.get_object("main_box") # self.main_box.set_property('width_request', 800) self.progressbar = self.ui.get_object("main_progressbar") self.progressbar.set_name('process_progressbar') self.forward_button = self.header_ui.get_object("forward_button") self.backwards_button = self.header_ui.get_object("backwards_button") atk_set_image_description(self.forward_button, _("Next step")) atk_set_image_description(self.backwards_button, _("Previous step")) self.forward_button.set_name('fwd_btn') self.forward_button.set_always_show_image(True) self.backwards_button.set_name('bk_btn') self.backwards_button.set_always_show_image(True) # Create a queue. Will be used to report pacman messages # (pacman/pac.py) to the main thread (installation/process.py) self.callback_queue = multiprocessing.JoinableQueue() # This list will have all processes (rankmirrors, autotimezone...) self.process_list = [] if cmd_line.packagelist: self.settings.set('alternate_package_list', cmd_line.packagelist) logging.info( "Using '%s' file as package list", self.settings.get('alternate_package_list')) self.set_titlebar(self.header) # Prepare params dict to pass common parameters to all screens self.params = dict() self.params['main_window'] = self self.params['header'] = self.header self.params['ui_dir'] = self.ui_dir self.params['forward_button'] = self.forward_button self.params['backwards_button'] = self.backwards_button self.params['callback_queue'] = self.callback_queue self.params['settings'] = self.settings self.params['main_progressbar'] = self.progressbar self.params['process_list'] = self.process_list self.params['checks_are_optional'] = cmd_line.no_check self.params['disable_tryit'] = cmd_line.disable_tryit self.params['disable_rank_mirrors'] = cmd_line.disable_rank_mirrors # Just load the first two screens (the other ones will be loaded later) # We do this so the user has not to wait for all the screens to be # loaded self.pages = dict() self.pages["welcome"] = welcome.Welcome(self.params) if os.path.exists('/home/antergos/.config/openbox'): # In minimal iso, load language screen now self.pages["language"] = language.Language(self.params) # Fix bugy Gtk window size when using Openbox self._main_window_width = 750 self._main_window_height = 450 self.connect('delete-event', self.on_exit_button_clicked) self.connect('key-release-event', self.on_key_release) self.ui.connect_signals(self) self.header_ui.connect_signals(self) nil, major, minor = info.CNCHI_VERSION.split('.') name = 'Cnchi ' title_string = "{0} {1}.{2}.{3}".format(name, nil, major, minor) self.set_title(title_string) self.header.set_title(title_string) self.header.set_subtitle(_("Antergos Installer")) self.header.set_show_close_button(True) self.tooltip_string = "{0} {1}.{2}.{3}".format(name, nil, major, minor) self.header.forall(self.header_for_all_callback, self.tooltip_string) self.set_geometry() # Set window icon icon_path = os.path.join( data_dir, "images", "antergos", "antergos-icon.png") self.set_icon_from_file(icon_path) # Set the first page to show # If minimal iso is detected, skip the welcome page. if os.path.exists('/home/antergos/.config/openbox'): self.current_page = self.pages["language"] self.settings.set('timezone_start', True) else: self.current_page = self.pages["welcome"] self.main_box.add(self.current_page) # Use our css file style_provider = Gtk.CssProvider() style_css = os.path.join(data_dir, "css", "gtk-style.css") with open(style_css, 'rb') as css: css_data = css.read() style_provider.load_from_data(css_data) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_USER ) # Show main window self.show_all() self.current_page.prepare('forwards') # Hide backwards button self.backwards_button.hide() self.progressbar.set_fraction(0) self.progressbar_step = 0 # Do not hide progress bar for minimal iso as it would break # the widget alignment on language page. if not os.path.exists('/home/antergos/.config/openbox'): # Hide progress bar self.progressbar.hide() self.set_focus(None) misc.gtk_refresh()
def setUp(self): '''Load the settings''' self.settings = config.Settings()
def draw_apples(apples): settings = config.Settings().settings for apple in apples: draw_xy(apple.x, apple.y, settings["apple_tile"])
def draw_snake(snake): settings = config.Settings().settings draw_xy(snake.head.x, snake.head.y, settings["head_tile"]) for part in snake.body: draw_xy(part.x, part.y, settings["tail_tile"]) draw_xy(snake.lastPos.x, snake.lastPos.y, settings["background_tile"])
def __init__(self): ## This allows to translate all py texts (not the glade ones) #gettext.textdomain(APP_NAME) #gettext.bindtextdomain(APP_NAME, LOCALE_DIR) # #locale_code, encoding = locale.getdefaultlocale() #lang = gettext.translation(APP_NAME, LOCALE_DIR, [locale_code], None, True) #lang.install() # ## With this we can use _("string") to translate #gettext.install(APP_NAME, localedir=LOCALE_DIR, codeset=None, names=[locale_code]) # Check if we have administrative privileges if os.getuid() != 0: show.fatal_error( _('This installer must be run with administrative' ' privileges and cannot continue without them.')) setup_logging() # Check if we're already running tmp_running = "/tmp/.setup-running" if os.path.exists(tmp_running): show.error( _('You cannot run two instances of this installer.\n\n' 'If you are sure that another installer is not already running\n' 'you can manually delete the file %s\n' 'and run this installer again.') % tmp_running) sys.exit(1) super().__init__() # workaround for dconf os.system("mkdir -p /root/.cache/dconf") os.system("chmod -R 777 /root/.cache") logging.info(_("Thus installer version %s"), info.THUS_VERSION) current_process = multiprocessing.current_process() logging.debug("[%d] %s started", current_process.pid, current_process.name) self.settings = config.Settings() thus_dir = os.path.join(os.path.dirname(__file__), './') if os.path.exists(thus_dir): self.settings.set('thus', thus_dir) else: thus_dir = self.settings.get('thus') ui_dir = os.path.join(os.path.dirname(__file__), 'ui/') if os.path.exists(ui_dir): self.settings.set('ui', ui_dir) else: ui_dir = self.settings.get('ui') data_dir = os.path.join(os.path.dirname(__file__), 'data/') if os.path.exists(data_dir): self.settings.set('data', data_dir) else: data_dir = self.settings.get('data') if os.path.exists("/sys/firmware/efi"): self.settings.set('efi', True) self.ui = Gtk.Builder() self.ui.add_from_file(ui_dir + "thus.ui") self.add(self.ui.get_object("main")) self.header = self.ui.get_object("header") self.forward_button = self.ui.get_object("forward_button") self.logo = self.ui.get_object("logo") logo_dir = os.path.join(data_dir, "manjaro-logo-mini.png") self.logo.set_from_file(logo_dir) self.title = self.ui.get_object("title") # To honor our css self.title.set_name("header") self.logo.set_name("header") self.main_box = self.ui.get_object("main_box") self.progressbar = self.ui.get_object("progressbar1") self.forward_button = self.ui.get_object("forward_button") self.exit_button = self.ui.get_object("exit_button") self.backwards_button = self.ui.get_object("backwards_button") # Create a queue. Will be used to report pacman messages (pac.py) # to the main thread (installer_*.py) self.callback_queue = multiprocessing.JoinableQueue() # Load all pages # (each one is a screen, a step in the install process) self.pages = dict() params = dict() params['title'] = self.title params['forward_button'] = self.forward_button params['backwards_button'] = self.backwards_button params['exit_button'] = self.exit_button params['callback_queue'] = self.callback_queue params['settings'] = self.settings params['main_progressbar'] = self.ui.get_object('progressbar1') params['alternate_package_list'] = "" params['testing'] = cmd_line.testing self.pages["language"] = language.Language(params) self.pages["location"] = location.Location(params) self.pages["check"] = check.Check(params) self.pages["keymap"] = keymap.Keymap(params) self.pages["timezone"] = timezone.Timezone(params) self.pages["installation_ask"] = installation_ask.InstallationAsk( params) self.pages[ "installation_automatic"] = installation_automatic.InstallationAutomatic( params) self.pages[ "installation_alongside"] = installation_alongside.InstallationAlongside( params) self.pages[ "installation_advanced"] = installation_advanced.InstallationAdvanced( params) self.pages["user_info"] = user_info.UserInfo(params) self.pages["slides"] = slides.Slides(params) self.connect("delete-event", Gtk.main_quit) self.ui.connect_signals(self) self.set_title(_('Manjaro Installer')) self.set_position(Gtk.WindowPosition.CENTER) self.set_resizable(False) self.set_size_request(MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT) # Set window icon icon_dir = os.path.join(data_dir, 'manjaro-icon.png') self.set_icon_from_file(icon_dir) # Set the first page to show self.current_page = self.pages["language"] self.main_box.add(self.current_page) # Header style testing style_provider = Gtk.CssProvider() style_css = os.path.join(data_dir, "css", "gtk-style.css") with open(style_css, 'rb') as css: css_data = css.read() style_provider.load_from_data(css_data) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) # Show main window self.show_all() self.current_page.prepare('forwards') # Hide backwards button self.backwards_button.hide() # Hide titlebar but show border decoration self.get_window().set_accept_focus(True) #self.get_window().set_decorations(Gdk.WMDecoration.BORDER) # Hide progress bar as it's value is zero self.progressbar.set_fraction(0) self.progressbar.hide() self.progressbar_step = 1.0 / (len(self.pages) - 2) with open(tmp_running, "w") as tmp_file: tmp_file.write("Thus %d\n" % 1234) GLib.timeout_add(1000, self.pages["slides"].manage_events_from_cb_queue)
def __init__(self, app, cmd_line): Gtk.Window.__init__(self, title="Cnchi", application=app) # Check if we have administrative privileges if os.getuid() != 0: show.error( _('This installer must be run with administrative' ' privileges, and cannot continue without them.')) sys.exit(1) # Check if we're already running tmp_running = "/tmp/.setup-running" if os.path.exists(tmp_running): show.error( _('You cannot run two instances of this installer.\n\n' 'If you are sure that the installer is not already running\n' 'you can manually delete the file %s\n' 'and run this installer again.') % tmp_running) sys.exit(1) logging.info(_("Cnchi installer version %s"), info.CNCHI_VERSION) self.settings = config.Settings() self.ui_dir = self.settings.get('ui') if not os.path.exists(self.ui_dir): cnchi_dir = os.path.join(os.path.dirname(__file__), './') self.settings.set('cnchi', cnchi_dir) ui_dir = os.path.join(os.path.dirname(__file__), 'ui/') self.settings.set('ui', ui_dir) data_dir = os.path.join(os.path.dirname(__file__), 'data/') self.settings.set('data', data_dir) self.ui_dir = self.settings.get('ui') if cmd_line.cache: self.settings.set('cache', cmd_line.cache) if cmd_line.copycache: self.settings.set('cache', cmd_line.copycache) self.settings.set('copy_cache', True) # For things we are not ready for users to test self.settings.set('z_hidden', cmd_line.z_hidden) # Set enabled desktops if self.settings.get('z_hidden'): self.settings.set("desktops", desktops.DESKTOPS_DEV) else: self.settings.set("desktops", desktops.DESKTOPS) self.ui = Gtk.Builder() self.ui.add_from_file(self.ui_dir + "cnchi.ui") self.add(self.ui.get_object("main")) self.header_ui = Gtk.Builder() self.header_ui.add_from_file(self.ui_dir + "header.ui") self.header = self.header_ui.get_object("header") self.logo = self.header_ui.get_object("logo") data_dir = self.settings.get('data') logo_path = os.path.join(data_dir, "images", "antergos", "antergos-logo-mini2.png") self.logo.set_from_file(logo_path) # To honor our css self.header.set_name("header") self.logo.set_name("logo") self.main_box = self.ui.get_object("main_box") self.progressbar = self.ui.get_object("main_progressbar") self.progressbar.set_name('process_progressbar') self.forward_button = self.header_ui.get_object("forward_button") self.backwards_button = self.header_ui.get_object("backwards_button") image1 = Gtk.Image() image1.set_from_icon_name("go-next", Gtk.IconSize.BUTTON) self.forward_button.set_label("") self.forward_button.set_image(image1) image2 = Gtk.Image() image2.set_from_icon_name("go-previous", Gtk.IconSize.BUTTON) self.backwards_button.set_label("") self.backwards_button.set_image(image2) # Create a queue. Will be used to report pacman messages (pacman/pac.py) # to the main thread (installation/process.py) self.callback_queue = multiprocessing.JoinableQueue() # Save in config if we have to use aria2 to download pacman packages self.settings.set("use_aria2", cmd_line.aria2) if cmd_line.aria2: logging.info(_("Using Aria2 to download packages - EXPERIMENTAL")) self.set_titlebar(self.header) # Load all pages # (each one is a screen, a step in the install process) params = dict() params['header'] = self.header params['ui_dir'] = self.ui_dir params['forward_button'] = self.forward_button params['backwards_button'] = self.backwards_button params['callback_queue'] = self.callback_queue params['settings'] = self.settings params['main_progressbar'] = self.progressbar if cmd_line.packagelist: params['alternate_package_list'] = cmd_line.packagelist logging.info(_("Using '%s' file as package list"), params['alternate_package_list']) else: params['alternate_package_list'] = "" params['disable_tryit'] = cmd_line.disable_tryit params['testing'] = cmd_line.testing self.pages = dict() self.pages["welcome"] = welcome.Welcome(params) self.pages["language"] = language.Language(params) self.pages["location"] = location.Location(params) self.pages["check"] = check.Check(params) self.pages["desktop"] = desktop.DesktopAsk(params) self.pages["features"] = features.Features(params) self.pages["keymap"] = keymap.Keymap(params) self.pages["timezone"] = timezone.Timezone(params) self.pages["installation_ask"] = installation_ask.InstallationAsk( params) self.pages[ "installation_automatic"] = installation_automatic.InstallationAutomatic( params) self.pages[ "installation_alongside"] = installation_alongside.InstallationAlongside( params) self.pages[ "installation_advanced"] = installation_advanced.InstallationAdvanced( params) self.pages["user_info"] = user_info.UserInfo(params) self.pages["slides"] = slides.Slides(params) self.connect('delete-event', self.on_exit_button_clicked) self.ui.connect_signals(self) self.header_ui.connect_signals(self) title = "Cnchi %s" % info.CNCHI_VERSION self.set_title(title) self.header.set_title(title) self.header.set_subtitle(_("Antergos Installer")) self.header.set_show_close_button(True) self.set_geometry() # Set window icon icon_path = os.path.join(data_dir, "images", "antergos", "antergos-icon.png") self.set_icon_from_file(icon_path) # Set the first page to show self.current_page = self.pages["welcome"] self.main_box.add(self.current_page) # Header style testing style_provider = Gtk.CssProvider() style_css = os.path.join(data_dir, "css", "gtk-style.css") with open(style_css, 'rb') as css: css_data = css.read() style_provider.load_from_data(css_data) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) # Show main window self.show_all() self.current_page.prepare('forwards') # Hide backwards button self.backwards_button.hide() # Hide titlebar but show border decoration #self.get_window().set_accept_focus(True) #self.get_window().set_decorations(Gdk.WMDecoration.BORDER) # Hide progress bar as it's value is zero self.progressbar.set_fraction(0) self.progressbar.hide() self.progressbar_step = 1.0 / (len(self.pages) - 2) with open(tmp_running, "w") as tmp_file: tmp_file.write("Cnchi %d\n" % 1234)
import aiofiles import ujson from aiocache import cached from ddtrace import patch_all from fastapi import FastAPI from starlette.requests import Request from starlette.responses import HTMLResponse, Response from starlette.staticfiles import StaticFiles from starlette.templating import Jinja2Templates from tortoise.contrib.fastapi import register_tortoise import config import form import models _settings = config.Settings() GRADE_NAME_FILE_NAME = 'grade_names.json' CAFE_NAME_FILE_NAME = 'cafe_names.json' QUIZ_FILE_NAME = 'quiz.json' app = FastAPI(title='Pilgrim', version='0.3.1', docs_url=None, redoc_url=None, openapi_url=None) app.mount('/static', StaticFiles(directory='static'), name='static') app.mount('/img', StaticFiles(directory=str(_settings.resource_path / _settings.image_path)), name='images')
def build(self): self.cnf = config.Settings() # load filter kernels self.cnf.kernels = flt.Kernels() self.cnf.numkernels = self.cnf.kernels.get_numkernels() self.cnf.flt_inp_name, self.cnf.inp_kernel, self.cnf.flt_inp_strength = self.cnf.kernels.get_kernel( self.cnf.flt_inp) self.cnf.flt_out_name, self.cnf.out_kernel, self.cnf.flt_out_strength = self.cnf.kernels.get_kernel( self.cnf.flt_out) # Kivy stuff # define widget animations self.ibar_in = Animation(pos_hint={'right': 0.1}) self.ibar_out = Animation(pos_hint={'right': 0}) self.obar_in = Animation(pos_hint={'right': 1}) self.obar_out = Animation(pos_hint={'right': 1.1}) self.outb_large = Animation(pos_hint={'x': 0, 'top': 1}, size_hint_x=1) self.outb_small = Animation( pos_hint={'x': 0.1, 'top': 1}, size_hint_x=0.8) self.inpb_large = Animation(pos_hint={'x': 0, 'top': 1}) self.inpb_small = Animation(pos_hint={'x': 0.1, 'top': 1}) self.bpan_in = Animation(pos_hint={'top': 0.1}) self.bpan_out = Animation(pos_hint={'top': 0}) self.tpan_in = Animation(pos_hint={'top': 1}) self.tpan_out = Animation(pos_hint={'top': 1.1}) self.help_out = Animation(pos_hint={'top': 2.2}) self.help_in = Animation(pos_hint={'top': 1}) # create Kivy UI self.cnf.rootwidget = MyScreen() self.namelist = ['FLT-OFF'] for k in range(1, self.cnf.numkernels): self.namelist.append(self.cnf.kernels.get_kernel(k)[0]) self.cnf.rootwidget.iflt_wid.values = self.namelist self.cnf.rootwidget.oflt_wid.values = self.namelist self.cnf.rootwidget.osd_wid.bind(state=self.osd_callback) self.cnf.rootwidget.vec_wid.bind(state=self.vec_callback) self.cnf.rootwidget.inp_wid.bind(state=self.inp_callback) self.cnf.rootwidget.out_wid.bind(state=self.out_callback) self.cnf.rootwidget.iauto_wid.bind(on_release=self.iauto_callback) self.cnf.rootwidget.igain_wid.bind(value=self.igain_callback) self.cnf.rootwidget.ioffset_wid.bind(value=self.ioffset_callback) self.cnf.rootwidget.oauto_wid.bind(on_release=self.oauto_callback) self.cnf.rootwidget.ogain_wid.bind(value=self.ogain_callback) self.cnf.rootwidget.ooffset_wid.bind(value=self.ooffset_callback) self.cnf.rootwidget.iblur_wid.bind(state=self.iblur_callback) self.cnf.rootwidget.idnz_wid.bind(state=self.idnz_callback) self.cnf.rootwidget.oblur_wid.bind(state=self.oblur_callback) self.cnf.rootwidget.odnz_wid.bind(state=self.odnz_callback) self.cnf.rootwidget.istab_wid.bind(state=self.istab_callback) self.cnf.rootwidget.ostab_wid.bind(state=self.ostab_callback) self.cnf.rootwidget.iequ_wid.bind(text=self.iequ_callback) self.cnf.rootwidget.oequ_wid.bind(text=self.oequ_callback) self.cnf.rootwidget.iflt_wid.bind(text=self.iflt_callback) self.cnf.rootwidget.oflt_wid.bind(text=self.oflt_callback) self.cnf.rootwidget.stack_wid.bind(value=self.stack_callback) self.cnf.rootwidget.proc_wid.bind(text=self.proc_callback) self.cnf.rootwidget.dark_wid.bind(state=self.dark_callback) self.cnf.rootwidget.reset_wid.bind(on_release=self.reset_callback) self.cnf.rootwidget.play_wid.bind(state=self.play_callback) self.cnf.rootwidget.loop_wid.bind(state=self.loop_callback) self.cnf.rootwidget.screenshot_wid.bind( on_release=self.screenshot_callback) self.cnf.rootwidget.video_wid.bind(state=self.video_callback) self.cnf.rootwidget.imagesequence_wid.bind( state=self.imagesequence_callback) self.cnf.rootwidget.help_wid.bind(state=self.help_callback) self.cnf.rootwidget.colors_wid.bind(on_release=self.colors_callback) self.cnf.rootwidget.flipx_wid.bind(state=self.flipx_callback) self.cnf.rootwidget.flipy_wid.bind(state=self.flipy_callback) # command line parser parser = argparse.ArgumentParser( description='Python Frame Sequence Processor', add_help=True) parser.add_argument('-c', '--config_file', default='none', help='Load Configuration from file') parser.add_argument('-is', '--input_source', default=self.cnf.video_src, help='Input Source, filename or camera index') parser.add_argument('-iw', '--input_width', default=self.cnf.video_width, help='Width of captured frames') parser.add_argument('-ih', '--input_height', default=self.cnf.video_height, help='Height of captured frames') parser.add_argument('-ib', '--input_blur', action='store_true', help='Blur Input') parser.add_argument('-ie', '--input_equalize', default=self.cnf.rootwidget.iequ_wid.text, help='Input Equalization Mode') parser.add_argument('-if', '--input_filter', default=self.cnf.rootwidget.iflt_wid.text, help='Set Input Filter') parser.add_argument('-ifs', '--input_filter_strength', default='none', help='Set Input Filter Strength') parser.add_argument('-ig', '--input_gain', default=self.cnf.rootwidget.igain_wid.value, help='Input Gain') parser.add_argument('-il', '--loop_input', action='store_true', help='Loop input video') parser.add_argument('-in', '--input_denoise', action='store_true', help='Input Denoise') parser.add_argument('-ii', '--input_stabilizer', action='store_true', help='Enable input image stabilizer') parser.add_argument('-bs', '--blur_strength', default=self.cnf.blr_strength, help='Blur Strength (Kernel Size') parser.add_argument('-fx', '--flip_x', action='store_true', help='Flip around X axis') parser.add_argument('-fy', '--flip_y', action='store_true', help='Flip around Y axis') parser.add_argument('-ob', '--output_blur', action='store_true', help='Blur Output') parser.add_argument('-oc', '--color_mode', default=self.cnf.rootwidget.colors_wid.text, help='Output Color Mode') parser.add_argument('-oe', '--output_equalize', default=self.cnf.rootwidget.oequ_wid.text, help='Output Equalization Mode') parser.add_argument('-of', '--output_filter', default=self.cnf.rootwidget.oflt_wid.text, help='Set Output Filter') parser.add_argument('-ofs', '--output_filter_strength', default='none', help='Set Output Filter Strength') parser.add_argument('-og', '--output_gain', default=self.cnf.rootwidget.ogain_wid.value, help='Output Gain') parser.add_argument('-oi', '--output_stabilizer', action='store_true', help='Enable output image stabilizer') parser.add_argument('-on', '--output_denoise', action='store_true', help='Output Denoise') parser.add_argument('-ov', '--output_video', default='none', help='Save output as video (Path or Prefix).') parser.add_argument('-os', '--output_images', default='none', help='Save output as image sequence (Path or Prefix).') parser.add_argument('-pm', '--processing_mode', default=self.cnf.rootwidget.proc_wid.text, help='Set Processing Mode') parser.add_argument('-pz', '--stack_size', default=self.cnf.rootwidget.stack_wid.value, help='Image Stacking (No. of frames to stack)') self.args = parser.parse_args(sys.argv[2:]) if str(self.args.input_source).isdigit(): self.cnf.video_src = int(self.args.input_source) else: self.cnf.video_src = self.args.input_source # initialize video input self.cnf.video_width = self.args.input_width self.cnf.video_height = self.args.input_height self.imageinput = vs.FrameInput( self.cnf.video_src, self.cnf.video_width, self.cnf.video_height) self.imageinput.loop = self.cnf.loop self.cnf.video_width = self.imageinput.frame_width self.cnf.video_height = self.imageinput.frame_height # prepare stack self.cnf.imagestack = fs.FrameStack( self.cnf.numframes, self.cnf.video_width, self.cnf.video_height) # apply loaded settings to stack self.apply_settings() # load command line arguments and update UI and settings self.update_controls(self.args) # create a CLAHE object (Contrast Limited Adaptive Histogram # Equalization) self.clahe = cv2.createCLAHE(clipLimit=4.0, tileGridSize=(4, 4)) # prepare on screen vector display self.center_x = int(self.cnf.video_width / 2) self.center_y = int(self.cnf.video_height / 2) self.center = (self.center_x, self.center_y) self.vec_zoom_2 = self.cnf.vec_zoom / 2 self.background = np.full((self.cnf.video_height, self.cnf.video_width, 3), self.cnf.imagestack.default_value, np.uint8) # prepare image stabilizer self.inp = self.imageinput.grab_frame() self.inp = cv2.cvtColor(self.inp, cv2.COLOR_BGR2GRAY) self.inp_old = self.inp.copy() self.inp_raw = self.inp.copy() self.dsp_old = self.inp.copy() self.dsp_raw = self.inp.copy() Clock.schedule_interval(self.update, 1.0 / 33.0) return self.cnf.rootwidget
newstart -- float, can be used as the start variable for the next calling of interval() """ Elapsed = time.time() - start if Elapsed < 600: IntervalTime = str(round(time.time() - start, decimals)) + " Seconds" else: IntervalTime = str(round(time.time() - start) / 60) + " Minutes" if location != False: print(IntervalTime + " at location " + str(number)) newstart = time.time() return IntervalTime, newstart if __name__ == "__main__": cfg = config.Settings() # Load the settings with which to run the # pipeline. SkipSteps = cfg['SkipSteps'] # Which steps of the pipeline to skip start = time.time() # Time indicator for when the pipeline was started # Add all the arguments to a textfile that will later contain the # unclassified structures. This way you can add a comment in the # command line which will end up in the output. with open(cfg['UnclassifiedFile'], 'w') as w: w.write("Arguments: " + str(sys.argv) + "\n") #Create folder for the ClassyFireJsonFiles if it doesnt exist try: os.mkdir('ClassyFireJsonFiles') except: print("ClassyFireJsonFiles already exists.")
def __init__(self, app, cmd_line): Gtk.ApplicationWindow.__init__(self, title="Thus", application=app) # Check if we have administrative privileges if os.getuid() != 0: msg = _('This installer must be run with administrative privileges, ' 'and cannot continue without them.') show.error(self, msg) sys.exit(1) # Check if we're already running tmp_running = "/tmp/.setup-running" if os.path.exists(tmp_running): logging.error(_("File '{0}' already exists.".format(tmp_running))) msg = _("You cannot run two instances of this installer.\n\n" "If you are sure that the installer is not already running\n" "you can run this installer using the --force option\n" "or you can manually delete the offending file.\n\n" "Offending file: '{0}'").format(tmp_running) show.error(self, msg) sys.exit(1) # workaround for dconf os.system("mkdir -p /root/.cache/dconf") os.system("chmod -R 777 /root/.cache") logging.info(_("Thus installer version {0}".format(info.THUS_VERSION))) self.settings = config.Settings() self.ui_dir = self.settings.get('ui') if not os.path.exists(self.ui_dir): thus_dir = os.path.join(os.path.dirname(__file__), './') self.settings.set('thus', thus_dir) ui_dir = os.path.join(os.path.dirname(__file__), 'ui/') self.settings.set('ui', ui_dir) data_dir = os.path.join(os.path.dirname(__file__), 'data/') self.settings.set('data', data_dir) self.ui_dir = self.settings.get('ui') '''if cmd_line.cache: logging.debug("Thus will use '{0}' as a source directory for cached xz packages".format(cmd_line.cache)) self.settings.set('cache', cmd_line.cache)''' data_dir = self.settings.get('data') # For things we are not ready for users to test self.settings.set('z_hidden', cmd_line.z_hidden) self.ui = Gtk.Builder() path = os.path.join(self.ui_dir, "main_window.ui") self.ui.add_from_file(path) self.add(self.ui.get_object("main")) self.header = self.ui.get_object("header") self.logo = self.ui.get_object("logo") path = os.path.join(data_dir, "images", "manjaro", "manjaro-logo-mini.png") self.logo.set_from_file(path) self.title = self.ui.get_object("title") # To honor our css self.header.set_name("header") self.logo.set_name("logo") self.main_box = self.ui.get_object("main_box") self.progressbar = self.ui.get_object("main_progressbar") self.progressbar.set_name('process_progressbar') self.forward_button = self.ui.get_object("forward_button") self.exit_button = self.ui.get_object("exit_button") self.backwards_button = self.ui.get_object("backwards_button") # image1 = Gtk.Image.new_from_icon_name("go-next", Gtk.IconSize.LARGE_TOOLBAR) # self.forward_button.set_label("") # self.forward_button.set_image(image1) # self.forward_button.set_name('fwd_btn') # self.forward_button.set_always_show_image(True) # self.forward_button.add(Gtk.Arrow(Gtk.ArrowType.RIGHT, Gtk.ShadowType.NONE)) # image2 = Gtk.Image.new_from_icon_name("go-previous", Gtk.IconSize.LARGE_TOOLBAR) # self.backwards_button.set_label("") # self.backwards_button.set_image(image2) self.backwards_button.set_name('bk_btn') self.backwards_button.set_always_show_image(True) # self.backwards_button.add(Gtk.Arrow(Gtk.ArrowType.LEFT, Gtk.ShadowType.NONE)) # Create a queue. Will be used to report pacman messages (pacman/pac.py) # to the main thread (installation/process.py) self.callback_queue = multiprocessing.JoinableQueue() '''# Save in config if we have to use aria2 to download pacman packages self.settings.set("use_aria2", cmd_line.aria2) if cmd_line.aria2: logging.info(_("Using Aria2 to download packages - EXPERIMENTAL"))''' # self.set_titlebar(self.header) # Prepare params dict to pass common parameters to all screens self.params = dict() self.params['title'] = self.title self.params['header'] = self.header self.params['ui_dir'] = self.ui_dir self.params['forward_button'] = self.forward_button self.params['exit_button'] = self.exit_button self.params['backwards_button'] = self.backwards_button self.params['callback_queue'] = self.callback_queue self.params['settings'] = self.settings self.params['main_progressbar'] = self.progressbar # self.params['disable_tryit'] = cmd_line.disable_tryit self.params['testing'] = cmd_line.testing # Just load the first two screens (the other ones will be loaded later) # We do this so the user has not to wait for all the screens to be loaded self.pages = dict() self.pages["language"] = language.Language(self.params) self.connect('delete-event', self.on_exit_button_clicked) self.connect('key-release-event', self.check_escape) self.ui.connect_signals(self) self.set_title(_("Manjaro Installer - Thus {0}".format(info.THUS_VERSION))) self.set_geometry() #self.set_position(Gtk.WindowPosition.CENTER) #self.set_resizable(False) #self.set_size_request(MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT) # Set window icon icon_path = os.path.join(data_dir, "images", "manjaro", "manjaro-icon.png") self.set_icon_from_file(icon_path) # Set the first page to show self.current_page = self.pages["language"] self.settings.set('timezone_start', True) self.main_box.add(self.current_page) # Use our css file (not in minimal, looks better without) # Sorry, not anymore thanks to gtk 3.16 style_provider = Gtk.CssProvider() style_css = os.path.join(data_dir, "css", "gtk-style.css") with open(style_css, 'rb') as css: css_data = css.read() style_provider.load_from_data(css_data) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_USER ) # Show main window self.show_all() self.current_page.prepare('forwards') # Hide backwards button self.backwards_button.hide() self.progressbar.set_fraction(0) self.progressbar_step = 0 ''' # Do not hide progress bar for minimal iso as it would break the widget alignment on language page. if not os.path.exists('/home/manjaro/.config/openbox'): # Hide progress bar self.progressbar.hide() ''' with open(tmp_running, "w") as tmp_file: tmp_file.write("Thus {0}\n".format(1234)) misc.gtk_refresh()
from flask import Flask, redirect, url_for import config app = Flask(__name__, template_folder='./src/templates') app.secret_key = config.Settings().SCR_KEY def getVersion(): return config.Settings().VERSION app.jinja_env.globals.update(getVersion=getVersion) with app.app_context(): from src.auth.auth import auth_bp app.register_blueprint(auth_bp, url_prefix='/auth') from src.aluno.aluno import aluno_bp app.register_blueprint(aluno_bp, url_prefix='/alunos') from src.admin.admin import admin_bp app.register_blueprint(admin_bp, url_prefix='/admin') @app.route('/') def main(): return redirect('/alunos')
async def test_other_namespace(self): with mock.patch.dict(os.environ, NAMESPACE="PROD", PROD_DEBUG="0"): reload(config) s = config.Settings() self.assertEqual(s.DEBUG, False)
def getVersion(): return config.Settings().VERSION
ref=AttrRef(tool, "spawnProtection")) self.spawnProtectionLabel = Label("Spawn Position Safety") self.spawnProtectionLabel.mouse_down = self.spawnProtectionCheckBox.mouse_down tooltipText = "Minecraft will randomly move your spawn point if you try to respawn in a column where there are no blocks at Y=63 and Y=64. Only uncheck this box if Minecraft is changed." self.spawnProtectionLabel.tooltipText = self.spawnProtectionCheckBox.tooltipText = tooltipText row = Row((self.spawnProtectionCheckBox, self.spawnProtectionLabel)) col = Column((Label("Spawn Point Options"), row, Button("OK", action=self.dismiss))) self.add(col) self.shrink_wrap() SpawnSettings = config.Settings("Spawn") SpawnSettings.spawnProtection = SpawnSettings("Spawn Protection", True) class PlayerSpawnPositionTool(PlayerPositionTool): surfaceBuild = True toolIconName = "playerspawn" tooltipText = "Move Spawn Point" def __init__(self, *args): PlayerPositionTool.__init__(self, *args) self.optionsPanel = PlayerSpawnPositionOptions(self) def toolEnabled(self): return self.editor.level.dimNo == 0
def build(self): signal.signal(signal.SIGINT, self.signal_handler) self.cnf = config.Settings() # load filter kernels self.cnf.kernels = flt.Kernels() self.cnf.numkernels = self.cnf.kernels.get_numkernels() self.cnf.flt_inp_name, self.cnf.inp_kernel, self.cnf.flt_inp_strength = self.cnf.kernels.get_kernel( self.cnf.flt_inp) self.cnf.flt_out_name, self.cnf.out_kernel, self.cnf.flt_out_strength = self.cnf.kernels.get_kernel( self.cnf.flt_out) # Kivy stuff # define widget animations self.ibar_in = Animation(pos_hint={'right': 0.1}) self.ibar_out = Animation(pos_hint={'right': 0}) self.obar_in = Animation(pos_hint={'right': 1}) self.obar_out = Animation(pos_hint={'right': 1.1}) self.outb_large = Animation(pos_hint={'x': 0, 'top': 1}, size_hint_x=1) self.outb_small = Animation(pos_hint={ 'x': 0.1, 'top': 1 }, size_hint_x=0.8) self.inpb_large = Animation(pos_hint={'x': 0, 'top': 1}) self.inpb_small = Animation(pos_hint={'x': 0.1, 'top': 0.9}) self.bpan_in = Animation(pos_hint={'top': 0.1}) self.bpan_out = Animation(pos_hint={'top': 0}) self.tpan_in = Animation(pos_hint={'top': 1}) self.tpan_out = Animation(pos_hint={'top': 1.1}) # create Kivy UI self.cnf.rootwidget = MyScreen() self.namelist = ['FLT-OFF'] for k in range(1, self.cnf.numkernels): self.namelist.append(self.cnf.kernels.get_kernel(k)[0]) if not skvdetected: self.cnf.rootwidget.recorder_wid.values = ['Rec-OFF', 'Sequence'] self.cnf.rootwidget.iflt_wid.values = self.namelist self.cnf.rootwidget.oflt_wid.values = self.namelist self.cnf.rootwidget.osd_wid.bind(state=self.osd_callback) self.cnf.rootwidget.vec_wid.bind(state=self.vec_callback) self.cnf.rootwidget.inp_wid.bind(state=self.inp_callback) self.cnf.rootwidget.out_wid.bind(state=self.out_callback) self.cnf.rootwidget.iauto_wid.bind(state=self.iauto_callback) self.cnf.rootwidget.igain_wid.bind(value=self.igain_callback) self.cnf.rootwidget.ioffset_wid.bind(value=self.ioffset_callback) self.cnf.rootwidget.oauto_wid.bind(state=self.oauto_callback) self.cnf.rootwidget.ogain_wid.bind(value=self.ogain_callback) self.cnf.rootwidget.ooffset_wid.bind(value=self.ooffset_callback) self.cnf.rootwidget.iblur_wid.bind(state=self.iblur_callback) self.cnf.rootwidget.idnz_wid.bind(state=self.idnz_callback) self.cnf.rootwidget.oblur_wid.bind(state=self.oblur_callback) self.cnf.rootwidget.odnz_wid.bind(state=self.odnz_callback) self.cnf.rootwidget.iequ_wid.bind(text=self.iequ_callback) self.cnf.rootwidget.oequ_wid.bind(text=self.oequ_callback) self.cnf.rootwidget.iflt_wid.bind(text=self.iflt_callback) self.cnf.rootwidget.oflt_wid.bind(text=self.oflt_callback) self.cnf.rootwidget.stack_wid.bind(value=self.stack_callback) self.cnf.rootwidget.proc_wid.bind(text=self.proc_callback) self.cnf.rootwidget.dark_wid.bind(text=self.dark_callback) self.cnf.rootwidget.reset_wid.bind(on_release=self.reset_callback) self.cnf.rootwidget.dout_wid.bind(state=self.dout_callback) self.cnf.rootwidget.zero_wid.bind(on_release=self.zerooutput_callback) self.cnf.rootwidget.ichan_wid.bind(text=self.ichan_callback) self.cnf.rootwidget.indzoom_wid.bind(value=self.indzoom_callback) self.cnf.rootwidget.trf_wid.bind(text=self.trf_callback) self.cnf.rootwidget.playmode_wid.bind(text=self.playmode_callback) self.cnf.rootwidget.inifile_wid.bind(on_release=self.inifile_callback) self.cnf.rootwidget.recorder_wid.bind(text=self.recorder_callback) self.cnf.rootwidget.actuator_wid.bind(state=self.actuator_callback) self.cnf.rootwidget.override_wid.bind(state=self.override_callback) self.cnf.rootwidget.colors_wid.bind(text=self.colors_callback) self.cnf.rootwidget.flipx_wid.bind(state=self.flipx_callback) self.cnf.rootwidget.flipy_wid.bind(state=self.flipy_callback) self.cnf.rootwidget.ihist_wid.bind(state=self.ihist_callback) self.cnf.rootwidget.ohist_wid.bind(state=self.ohist_callback) self.cnf.rootwidget.istab_wid.bind(state=self.istab_callback) self.cnf.rootwidget.ostab_wid.bind(state=self.ostab_callback) self.cnf.rootwidget.oimage_wid.bind(size=self.oimage_size_callback) self.cnf.rootwidget.vectype_wid.bind(text=self.vectype_callback) Window.bind(on_joy_axis=self.on_joy_axis) Window.bind(on_joy_hat=self.on_joy_hat) Window.bind(on_joy_button_down=self.on_joy_button_down) # command line parser parser = argparse.ArgumentParser( description='Python Frame Sequence Processor', add_help=True) parser.add_argument( '-ac', '--actuator_class', help='Load actuator class from actuators.py: (Defaults to Paint)') parser.add_argument('-ap', '--actuator_parm', help='Parameter (IP etc.) for actuator') parser.add_argument('-bg', '--background_source', help='Background image or video') parser.add_argument('-bs', '--blur_strength', help='Blur Strength (Kernel Size') parser.add_argument('-c', '--config_file', help='Load Configuration from file') parser.add_argument( '-dm', '--darkframe_mode', help='Darkframe processing mode: Dark-OFF, DynDark, Static, Grey') parser.add_argument('-fx', '--flip_x', action='store_true', help='Flip around X axis') parser.add_argument('-fy', '--flip_y', action='store_true', help='Flip around Y axis') parser.add_argument('-fps', '--frames_second', help='Set processing frame rate') parser.add_argument('-hi', '--hide_input', action='store_true', help='Hide input image') parser.add_argument('-ho', '--hide_output', action='store_true', help='Hide output image') parser.add_argument( '-ic', '--input_channel', help= 'Input Channel: BW, R, G, B, H, S, V, Y, Cr, Cb, RND, RNDX, RNDXA, RNDXC' ) parser.add_argument( '-is', '--input_source', help='Input Source: Filename, camera index or PICAMERA') parser.add_argument('-iw', '--input_width', help='Width of captured frames') parser.add_argument('-ih', '--input_height', help='Height of captured frames') parser.add_argument( '-i4', '--input_fourcc', help='fourcc string for input camera codec. Default YUYV') parser.add_argument('-ib', '--input_blur', action='store_true', help='Blur Input') parser.add_argument('-ie', '--input_equalize', help='Input Equalization Mode') parser.add_argument('-if', '--input_filter', help='Set Input Filter') parser.add_argument('-ifs', '--input_filter_strength', help='Set Input Filter Strength') parser.add_argument('-ig', '--input_gain', help='Input Gain') parser.add_argument('-ii', '--input_stabilizer', action='store_true', help='Enable input image stabilizer') parser.add_argument('-in', '--input_denoise', action='store_true', help='Input Denoise') parser.add_argument('-l', '--log', help='Log to Filename or STDOUT') parser.add_argument('-ob', '--output_blur', action='store_true', help='Blur Output') parser.add_argument('-oc', '--color_mode', help='Output Color Mode') parser.add_argument( '-od', '--output_dir', help='Directory to save videos, images and logfiles.') parser.add_argument('-oe', '--output_equalize', help='Output Equalization Mode') parser.add_argument('-of', '--output_filter', help='Set Output Filter') parser.add_argument('-ofs', '--output_filter_strength', help='Set Output Filter Strength') parser.add_argument('-og', '--output_gain', help='Output Gain') parser.add_argument('-oi', '--output_stabilizer', action='store_true', help='Enable output image stabilizer') parser.add_argument('-on', '--output_denoise', action='store_true', help='Output Denoise') parser.add_argument('-or', '--output_recording', help='Record output: SEQ, VID') parser.add_argument('-ps', '--processing_state', help='Processing State: PLAY, LOOP, PAUSE') parser.add_argument('-pm', '--processing_mode', help='Set Processing Mode: AVG, DIFF, CUM-Z') parser.add_argument('-pz', '--stack_size', help='Image Stacking (No. of frames to stack)') parser.add_argument('-st', '--single_thread', action='store_true', help='Run appication as single thread') parser.add_argument('-tfm', '--trf_mode', help='Set Transient Filter Mode: Rise, Fall') parser.add_argument('-tft', '--trf_trigger', help='Set Transient Filter Triggerlevel') parser.add_argument('-vm', '--vector_mode', help='Set Vector Display / Data Mode: AVG, CUM-Z') parser.add_argument('-vz', '--vector_zoom', help='Set Vector Display / Output Zoom') self.args = parser.parse_args(sys.argv[1:]) self.apply_args() # initialize video input if self.cnf.raspicam: self.imageinput = vs.FrameInputPi(self.cnf.video_src, self.cnf.video_width, self.cnf.video_height, self.cnf) else: self.imageinput = vs.FrameInput(self.cnf.video_src, self.cnf.video_width, self.cnf.video_height, self.cnf) self.cnf.video_width = self.imageinput.frame_width self.cnf.video_height = self.imageinput.frame_height # prepare stack self.cnf.imagestack = fs.FrameStack(self.cnf.max_stacksize, self.cnf.numframes, self.cnf.video_width, self.cnf.video_height) # apply loaded settings to stack self.apply_settings() # create a CLAHE object (Contrast Limited Adaptive Histogram # Equalization) self.clahe = cv2.createCLAHE(clipLimit=4.0, tileGridSize=(4, 4)) # prepre background image self.cnf.background = np.full( (self.cnf.video_height, self.cnf.video_width, 3), self.cnf.imagestack.default_value, np.uint8) self.generate_xormasks() # prepare first frame self.inp = self.imageinput.grab_frame() self.cnf.out = self.inp.copy() self.cnf.disp_image = self.inp.copy() self.inp = cv2.cvtColor(self.inp, cv2.COLOR_BGR2GRAY) self.cnf.oimage = self.inp.copy() self.inp_old = self.inp.copy() self.inp_raw = self.inp.copy() self.dsp_old = self.inp.copy() self.dsp_raw = self.inp.copy() # load actuator self.oimage_size_callback(None, self.cnf.rootwidget.oimage_wid.size) try: class_ = getattr(acts, self.cnf.actuator_class) self.cnf.act = class_(self.cnf) except: self.cnf.actuator_class = 'Paint' class_ = getattr(acts, self.cnf.actuator_class) self.cnf.act = class_(self.cnf) # update UI and settings self.apply_ui_args() # run worker threads or loop self.apply_ui_args() if self.cnf.single_thread: Clock.schedule_interval(self.single_thread, self.cnf.output_fps) else: Clock.schedule_interval(self.update_output, self.cnf.output_fps) self.cnf.procthread = Thread(target=self.process_thread) self.cnf.procthread.start() return self.cnf.rootwidget
def __init__(self): # This allows to translate all py texts (not the glade ones) gettext.textdomain(APP) gettext.bindtextdomain(APP, DIR) locale_code, encoding = locale.getdefaultlocale() lang = gettext.translation (APP, DIR, [locale_code], None, True) lang.install() # With this we can use _("string") to translate gettext.install(APP, localedir=DIR, codeset=None, names=[locale_code]) if os.getuid() != 0: show.fatal_error(_('This installer must be run with administrative' ' privileges, and cannot continue without them.')) # check if we're already running tmp_running = "/tmp/.setup-running" if os.path.exists(tmp_running): show.error(_('You cannot run two instances of this installer.\n\n' 'If you are sure that the installer is not already running\n' 'you can manually delete the file %s\n' 'and run this installer again.') % tmp_running) sys.exit(1) super().__init__() self.settings = config.Settings() self.ui_dir = self.settings.get("UI_DIR") if not os.path.exists(self.ui_dir): cnchi_dir = os.path.join(os.path.dirname(__file__), './') self.settings.set("CNCHI_DIR", cnchi_dir) ui_dir = os.path.join(os.path.dirname(__file__), 'ui/') self.settings.set("UI_DIR", ui_dir) data_dir = os.path.join(os.path.dirname(__file__), 'data/') self.settings.set("DATA_DIR", data_dir) self.ui_dir = self.settings.get("UI_DIR") # set enabled desktops self.settings.set("desktops", _desktops) self.ui = Gtk.Builder() self.ui.add_from_file(self.ui_dir + "cnchi.ui") self.add(self.ui.get_object("main")) self.header = self.ui.get_object("box5") self.forward_button = self.ui.get_object("forward_button") self.logo = self.ui.get_object("logo") logo_dir = os.path.join(self.settings.get("DATA_DIR"), "antergos-logo-mini.png") self.logo.set_from_file(logo_dir) self.title = self.ui.get_object("title") # To honor our css self.title.set_name("header") self.logo.set_name("header") self.main_box = self.ui.get_object("main_box") self.progressbar = self.ui.get_object("progressbar1") self.forward_button = self.ui.get_object("forward_button") self.exit_button = self.ui.get_object("exit_button") self.backwards_button = self.ui.get_object("backwards_button") # Create a queue. Will be used to report pacman messages (pac.py) # to the main thread (installer_*.py) #self.callback_queue = queue.Queue(0) # Doing some tests with a LIFO queue #self.callback_queue = queue.LifoQueue(0) self.callback_queue = Queue() # save in config if we have to use aria2 to download pacman packages self.settings.set("use_aria2", _use_aria2) if _use_aria2: log.debug(_("Cnchi will use pm2ml and aria2 to download packages - EXPERIMENTAL")) # load all pages # (each one is a screen, a step in the install process) self.pages = dict() params = dict() params['title'] = self.title params['ui_dir'] = self.ui_dir params['forward_button'] = self.forward_button params['backwards_button'] = self.backwards_button params['exit_button'] = self.exit_button params['callback_queue'] = self.callback_queue params['settings'] = self.settings params['alternate_package_list'] = _alternate_package_list params['enable_alongside'] = _enable_alongside if len(_alternate_package_list) > 0: log.debug(_("Using '%s' file as package list") % _alternate_package_list) self.pages["welcome"] = welcome.Welcome(params) self.pages["language"] = language.Language(params) self.pages["location"] = location.Location(params) self.pages["check"] = check.Check(params) self.pages["desktop"] = desktop.DesktopAsk(params) self.pages["keymap"] = keymap.Keymap(params) self.pages["timezone"] = timezone.Timezone(params) self.pages["installation_ask"] = installation_ask.InstallationAsk(params) self.pages["installation_automatic"] = installation_automatic.InstallationAutomatic(params) self.pages["installation_alongside"] = installation_alongside.InstallationAlongside(params) self.pages["installation_advanced"] = installation_advanced.InstallationAdvanced(params) self.pages["user_info"] = user_info.UserInfo(params) self.pages["slides"] = slides.Slides(params) self.connect("delete-event", Gtk.main_quit) self.ui.connect_signals(self) self.set_title(_('Antergos Installer')) self.set_position(Gtk.WindowPosition.CENTER) self.set_resizable(False) self.set_size_request(_main_window_width, _main_window_height); # set window icon icon_dir = os.path.join(self.settings.get("DATA_DIR"), 'antergos-icon.png') self.set_icon_from_file(icon_dir) # set the first page to show self.current_page = self.pages["welcome"] self.main_box.add(self.current_page) # Header style testing style_provider = Gtk.CssProvider() style_css = os.path.join(self.settings.get("DATA_DIR"), "css", "gtk-style.css") with open(style_css, 'rb') as css: css_data = css.read() style_provider.load_from_data(css_data) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION ) # show main window self.show_all() self.current_page.prepare('forwards') # hide backwards button self.backwards_button.hide() # Hide titlebar but show border decoration self.get_window().set_accept_focus(True) self.get_window().set_decorations(Gdk.WMDecoration.BORDER) # hide progress bar as it's value is zero self.progressbar.set_fraction(0) self.progressbar.hide() self.progressbar_step = 1.0 / (len(self.pages) - 2) # we drop privileges, but where we should do it? before this? ¿? misc.drop_privileges() with open(tmp_running, "wt") as tmp_file: tmp_file.write("Cnchi %d\n" % 1234) GLib.timeout_add(100, self.pages["slides"].manage_events_from_cb_queue)
async def test_debug_is_false(self): with mock.patch.dict(os.environ, DEV_DEBUG="0"): s = config.Settings() self.assertEqual(s.DEBUG, False)
import pygame from albow import Label, Button, Column from depths import DepthOffset from editortools.blockpicker import BlockPicker from editortools.blockview import BlockButton from editortools.editortool import EditorTool from editortools.tooloptions import ToolOptions from glbackground import Panel from glutils import Texture from mceutils import showProgress, CheckBoxLabel, alertException, setWindowCaption from operation import Operation import config import pymclevel FillSettings = config.Settings("Fill") FillSettings.chooseBlockImmediately = FillSettings("Choose Block Immediately", True) class BlockFillOperation(Operation): def __init__(self, editor, destLevel, destBox, blockInfo, blocksToReplace): super(BlockFillOperation, self).__init__(editor, destLevel) self.destBox = destBox self.blockInfo = blockInfo self.blocksToReplace = blocksToReplace def name(self): return "Fill with " + self.blockInfo.name def perform(self, recordUndo=True):
def get_settings(): return config.Settings()
# choose between generic and Raspberry Pi camera support import videosource as vs #import videosource_pi as vs import framestacker as fs import filters as flt # scikit-video (scikit-video.org) is used for recording because of OpenCV # Linux bug try: from skvideo.io import FFmpegWriter as VideoWriter skvdetected = True except: skvdetected = False cnf = config.Settings() def nothing(par): return def signal_handler(signal, frame): imageinput.exit_thread = True sys.exit(0) def gettime(): timestring = time.strftime("%Y%m%d-%H%M%S", time.gmtime()) return timestring
from topicsentiment.dataset import PandasDataset, TorchDataset from transformers import BertTokenizer, BertConfig import config from topicsentiment.model import BertForMultiLabel, Trainer, FocalLossLogits import pandas as pd import torch import argparse import logging import os import sys config = config.Settings() # Setting up logger logging.basicConfig() logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) fh = logging.FileHandler(os.path.join(config.MODEL_DIR, 'training.log')) fh.setLevel(logging.DEBUG) ch = logging.StreamHandler() ch.setLevel(logging.ERROR) formatter = logging.Formatter( '%(asctime)s - %(name)s - %(levelname)s - %(message)s') fh.setFormatter(formatter) ch.setFormatter(formatter) logger.addHandler(fh) logger.addHandler(ch) def pre_process(filename: str = 'sentisum-evaluation-dataset.csv', verbose: bool = False):
def run(page_name): """ Run page to be able to test it """ window = Gtk.Window() window.connect('destroy', Gtk.main_quit) # window.set_size_request(600, 500) window.set_border_width(0) window.set_title("Cnchi - Test of {0} page".format(page_name)) import logging logger = logging.getLogger() logger.setLevel(logging.DEBUG) stream_handler = logging.StreamHandler() stream_handler.setLevel(logging.DEBUG) formatter = logging.Formatter( '[%(asctime)s] [%(module)s] %(levelname)s: %(message)s', "%Y-%m-%d %H:%M:%S") stream_handler.setFormatter(formatter) logger.addHandler(stream_handler) # Use our css file style_provider = Gtk.CssProvider() style_css = "/usr/share/cnchi/data/css/gtk-style.css" if os.path.exists(style_css): with open(style_css, 'rb') as css: css_data = css.read() style_provider.load_from_data(css_data) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_USER) else: logging.warning("Cannot load CSS data") import config settings = config.Settings() settings.set('data', '/usr/share/cnchi/data') from desktop_info import DESKTOPS settings.set('desktops', DESKTOPS) settings.set('language_code', 'ca') params = { 'a11y': False, 'title': "Cnchi", 'main_window': window, 'ui_dir': "/usr/share/cnchi/ui", 'disable_tryit': False, 'settings': settings, 'forward_button': Gtk.Button.new(), 'backwards_button': Gtk.Button.new(), 'main_progressbar': Gtk.ProgressBar.new(), 'header': Gtk.HeaderBar.new(), 'callback_queue': None, 'alternate_package_list': "", 'process_list': [] } page = get_page(page_name, params) if page is not None: # page.set_property("halign", Gtk.Align.CENTER) window.add(page) window.show_all() page.prepare('forward') Gtk.main() else: print("Unknown page")