def main(): print( "Welcome to EZSlides! Are you capturing from a live lecture or a pre-recorded video?" ) print("1: Live lecture") print("2: Pre-recorded video") lectureType = input("Enter 1 or 2: ") path = None while True: if (lectureType == '1'): print("EZSlides will capture from your screen.") break elif (lectureType == '2'): print("EZSlides will capture from the video file.") while True: path = input("Please enter a valid video path: ") if os.path.isfile(path): break break else: print("Invalid input. Try again.") lectureType = input("Enter 1 or 2: ") print("Where would you like to store your text?") print("1: Text file") print("2: Clipboard") outputChoice = input("Enter 1 or 2: ") while True: if (outputChoice == '1'): print("Presentation text will be writted to a result.txt.") break elif (outputChoice == '2'): print("Presentation text will be copied to your clipboard.") break else: print("Invalid input. Try again.") outputChoice = input("Enter 1 or 2: ") if lectureType == '1': image = pyautogui.screenshot() image = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR) cv2.imwrite("media/prelim.png", image) cropCoords = analyze.getCoordinates() live = slides.Slides(None, cropCoords) live.liveFeed() else: vidObj = cv2.VideoCapture("media/test lecture.mp4") frame = None for i in range(10): success, frame = vidObj.read() # DISPLAY <frame> cv2.imwrite("media/prelim.png", frame) cropCoords = analyze.getCoordinates() # vidObj.release() vid = slides.Slides(path, cropCoords) vid.videoFeed() analyze.analyzeImages()
def load_pages(self): # misc.set_cursor(Gdk.CursorType.WATCH) self.pages["location"] = location.Location(self.params) self.pages["check"] = check.Check(self.params) self.pages["keymap"] = keymap.Keymap(self.params) self.pages["timezone"] = timezone.Timezone(self.params) self.pages["installation_ask"] = installation_ask.InstallationAsk(self.params) self.pages["installation_automatic"] = installation_automatic.InstallationAutomatic(self.params) if self.settings.get("enable_alongside"): self.pages["installation_alongside"] = installation_alongside.InstallationAlongside(self.params) else: self.pages["installation_alongside"] = None self.pages["installation_advanced"] = installation_advanced.InstallationAdvanced(self.params) self.pages["user_info"] = user_info.UserInfo(self.params) self.pages["slides"] = slides.Slides(self.params) # misc.set_cursor(Gdk.CursorType.ARROW) diff = 2 num_pages = len(self.pages) - diff if num_pages > 0: self.progressbar_step = 1.0 / num_pages
def get_screen(screen_name, params): screen = None if screen_name == "DesktopAsk": import desktop screen = desktop.DesktopAsk(params) elif screen_name == "Check": from modules.pages import check screen = check.Check(params) elif screen_name == "Timezone": import timezone screen = timezone.Timezone(params) params['settings'].set('timezone_start', True) elif screen_name == "Wireless": import wireless screen = wireless.Wireless(params) elif screen_name == "Welcome": import welcome screen = welcome.Welcome(params) elif screen_name == "UserInfo": import user_info screen = user_info.UserInfo(params) elif screen_name == "Location": import location screen = location.Location(params) elif screen_name == "Language": import language screen = language.Language(params) elif screen_name == "Keymap": import keymap screen = keymap.Keymap(params) elif screen_name == "Features": import features screen = features.Features(params) elif screen_name == "Summary": import summary screen = summary.Summary(params) elif screen_name == "Slides": import slides screen = slides.Slides(params) elif screen_name == "InstallationAsk": import ask screen = ask.InstallationAsk(params) elif screen_name == "InstallationAdvanced": import advanced screen = advanced.InstallationAdvanced(params) elif screen_name == "InstallationAlongside": import alongside screen = alongside.InstallationAlongside(params) elif screen_name == "InstallationAutomatic": import automatic screen = automatic.InstallationAutomatic(params) elif screen_name == "zfs": import zfs screen = zfs.InstallationZFS(params) return screen
def load_pages(self): if not os.path.exists('/home/reborn/.config/openbox'): self.pages["language"] = language.Language(self.params) self.pages["check"] = check.Check(self.params) self.pages["location"] = location.Location(self.params) self.pages["mirrors"] = mirrors.Mirrors(self.params) self.pages["timezone"] = timezone.Timezone(self.params) if self.settings.get('desktop_ask'): self.pages["keymap"] = keymap.Keymap(self.params) self.pages["desktop"] = desktop.DesktopAsk(self.params) self.pages["features"] = features.Features(self.params) else: self.pages["keymap"] = keymap.Keymap(self.params, next_page='features') self.pages["features"] = features.Features(self.params, prev_page='keymap') self.pages["installation_ask"] = installation_ask.InstallationAsk( self.params) self.pages[ "installation_automatic"] = installation_automatic.InstallationAutomatic( self.params) if self.settings.get("enable_alongside"): self.pages[ "installation_alongside"] = installation_alongside.InstallationAlongside( self.params) else: self.pages["installation_alongside"] = None self.pages[ "installation_advanced"] = installation_advanced.InstallationAdvanced( self.params) self.pages["installation_zfs"] = installation_zfs.InstallationZFS( self.params) self.pages["summary"] = summary.Summary(self.params) self.pages["user_info"] = user_info.UserInfo(self.params) self.pages["slides"] = slides.Slides(self.params) diff = 2 if os.path.exists('/home/antergos/.config/openbox'): # In minimal (openbox) we don't have a welcome screen diff = 3 num_pages = len(self.pages) - diff if num_pages > 0: self.progressbar_step = 1.0 / num_pages
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)
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): # 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)