def __init__(self, controlhandler): self.controlhandler = controlhandler GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) self.currentInstr = None self.ledState = 1 self.ledDriver = libDriver.LedDriver() self.pitch_click = libSwitch.Switch(22) # Pitch Encoder Click GPIO self.speed_click = libSwitch.Switch(26) # Speed Encoder Click GPIO # Set up Rotary Encoders self.encoder_pitch = libEnc.Encoder.Worker(17, 27) self.encoder_pitch.start() # Start Interrupt in a separate thread. self.encoder_speed = libEnc.Encoder.Worker(6, 13) self.encoder_speed.start() # Start Interrupt in a separate thread. self.pitch_delay = 0 self.speed_delay = 0 self.pitch_inc_dir = 0 self.speed_inc_dir = 0 self.encoder_delay_time = 500 self.now = int(round(time.time() * 1000)) self.pitch_blink_anim_flag = False self.pitch_blink_timer = self.now # Below are just the Blue on all RGB LEDs # Deltas for Encoders self.delta_p = 0 self.delta_s = 0 # Real Control Values (later share this with ControlHandler class self.speed_amount = self.controlhandler.getStaticVal("speed") self.alt_speed_amount = 23 # input level self.pitch_amount = self.controlhandler.getStaticVal("pitch") self.mode = "normal" user_dir = "/home/alarm/instr/" factory_dir = "/home/alarm/QB_Nebulae_V2/Code/instr/" pd_dir = "/home/alarm/pd/" self.factoryinstr_fhandle = filehandler.FileHandler( factory_dir, ".instr") self.userinstr_fhandle = filehandler.FileHandler(user_dir, ".instr") self.puredata_fhandle = filehandler.FileHandler(pd_dir, ".pd") cur_bank = self.controlhandler.getInstrSelBank() self.bank_shift_counter = 0 if cur_bank == "factory": cnt = self.factoryinstr_fhandle.numFiles() elif cur_bank == "user": cnt = self.userinstr_fhandle.numFiles() elif cur_bank == "puredata": cnt = self.puredata_fhandle.numFiles() self.controlhandler.setInstrSelNumFiles(cnt) self.reload_flag = False # Flag to reload the whole program. self.alt_file_bright = 0.0 self.alt_file_cnt = 0.0 self.blink_counter = 0 self.prev_blink = False self.blink = False self.time_pressed_pitch = self.now self.ignore_next_pitch_click = False self.ignore_next_speed_click = False self.clearAllLEDs() self.restoreDefaultsFlag = False
def __init__(self): self.instrparser = instrparser.InstrParser() self.source = "factory" self.instr = "granular_test" if self.source is "factory": self.instr_dir = "instr/" elif self.source is "user": #self.instr_dir = "/home/alarm/instr/" pass self.dir = "audio/" self.filehandler = fh.FileHandler(self.dir, [".wav", ".aif", ".aiff"])
def process_request(self, request): """ Processes given request creating a command out of it and forwarding it to file handler. Once it has been handled, process returned value to return results to search engine. :request: userrequests.Request : Request to be handled. """ self.req = request command = self.get_command() file_handler = filehandler.FileHandler(command) file_handler.handle_command() return command.result
def __init__(self): # internal utilities # set temp loglevel, while loading config temploglevel = config.Config.default["loglevel"] self.logger = logger.Logger(self, temploglevel) self.config = config.Config(self) self.cryptohandler = cryptohandler.CryptoHandler(self) self.filehandler = filehandler.FileHandler(self) # test crypto self.readfile = self.readfile() self.rsakey = self.genrsakey() self.rsa_encrypt = self.rsa_encrypt() self.aes_encrypt = self.aes_encrypt() self.rsa_decrypt = self.rsa_decrypt() self.aes_decrypt = self.aes_decrypt() self.filehandler.write_chunk(self.aes_decrypt)
def __open(self): fname = QtGui.QFileDialog.getOpenFileName(self.MainWindow, "Open file", "", "safe files " "(*.safe)") fname = str(fname) if fname is not "": if self.new(): try: fh = filehandler.FileHandler(fname) fh.open(self.plainTextEdit) return True except UnicodeError: QtGui.QMessageBox.critical( self.MainWindow, "Message", "Cannot open this kind of" "files") except IOError: QtGui.QMessageBox.critical(self.MainWindow, "Message", "Cannot open this file") return False
def __save(self): fname = QtGui.QFileDialog.getSaveFileName(self.MainWindow, "Save file", "", "safe files " "(*.safe)") fname = str(fname) if fname is not "": if not fname.endswith(".safe"): fname += ".safe" try: fh = filehandler.FileHandler(fname) fh.save(self.plainTextEdit) return True except UnicodeError: QtGui.QMessageBox.critical( self.MainWindow, "Message", "Cannot save this file, use only" " ascii characters") except IOError: QtGui.QMessageBox.critical(self.MainWindow, "Message", "Cannot write this file") return False
def __init__(self): self.game_state = self.State.INITIALIZING os.environ["SDL_VIDEO_CENTERED"] = "1" pygame.init() self.frame_timer = pygame.time.Clock() self.input_handler = input.Input() self.input_handler.add_listener(self) self.main_menu = menu.Menu() self.main_menu.add_listener(self) self.file_handler = filehandler.FileHandler() self.settings = {"GridWidth": 10, "GridHeight": 10, "MineCount": 20} proposed_grid_width = self.file_handler.get_setting("GridWidth", 5, 35) if proposed_grid_width != None: self.settings["GridWidth"] = proposed_grid_width proposed_grid_height = self.file_handler.get_setting( "GridHeight", 5, 30) if proposed_grid_height != None: self.settings["GridHeight"] = proposed_grid_height proposed_mine_count = self.file_handler.get_setting( "MineCount", 1, self.settings["GridWidth"] * self.settings["GridHeight"] - 1) if proposed_mine_count != None: self.settings["MineCount"] = proposed_mine_count
def __init__(self, animate_gifs=False, fullscreen=False, show_library=False, open_path=None, open_page=1): gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) # ---------------------------------------------------------------- # Attributes # ---------------------------------------------------------------- self.is_fullscreen = False self.is_double_page = False self.is_manga_mode = False self.is_virtual_double_page = False # I.e. a wide image is displayed self.zoom_mode = preferences.ZOOM_MODE_BEST self.width = None self.height = None self._manual_zoom = 100 # In percent of original image size self._waiting_for_redraw = False self.file_handler = filehandler.FileHandler(self) self.thumbnailsidebar = thumbbar.ThumbnailSidebar(self) self.statusbar = status.Statusbar() self.slideshow = slideshow.Slideshow(self) self.cursor_handler = cursor.CursorHandler(self) self.enhancer = enhance.ImageEnhancer(self) self.glass = lens.MagnifyingGlass(self) self.ui_manager = ui.MainUI(self) self.menubar = self.ui_manager.get_widget('/Menu') self.toolbar = self.ui_manager.get_widget('/Tool') self.popup = self.ui_manager.get_widget('/Popup') self.actiongroup = self.ui_manager.get_action_groups()[0] self.left_image = gtk.Image() self.right_image = gtk.Image() self._image_box = gtk.HBox(False, 2) self._main_layout = gtk.Layout() self._event_handler = event.EventHandler(self) self._vadjust = self._main_layout.get_vadjustment() self._hadjust = self._main_layout.get_hadjustment() self._vscroll = gtk.VScrollbar(self._vadjust) self._hscroll = gtk.HScrollbar(self._hadjust) # ---------------------------------------------------------------- # Setup # ---------------------------------------------------------------- self.set_title('Comix') self.set_size_request(300, 300) # Avoid making the window *too* small self.resize(prefs['window width'], prefs['window height']) # This is a hack to get the focus away from the toolbar so that # we don't activate it with space or some other key (alternative?) self.toolbar.set_focus_child( self.ui_manager.get_widget('/Tool/expander')) self.toolbar.set_style(gtk.TOOLBAR_ICONS) self.toolbar.set_icon_size(gtk.ICON_SIZE_LARGE_TOOLBAR) self._image_box.add(self.left_image) self._image_box.add(self.right_image) self._image_box.show_all() self._main_layout.put(self._image_box, 0, 0) self.set_bg_colour(prefs['bg colour']) self._vadjust.step_increment = 15 self._vadjust.page_increment = 1 self._hadjust.step_increment = 15 self._hadjust.page_increment = 1 table = gtk.Table(2, 2, False) table.attach(self.thumbnailsidebar, 0, 1, 2, 5, gtk.FILL, gtk.FILL | gtk.EXPAND, 0, 0) table.attach(self._main_layout, 1, 2, 2, 3, gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND, 0, 0) table.attach(self._vscroll, 2, 3, 2, 3, gtk.FILL | gtk.SHRINK, gtk.FILL | gtk.SHRINK, 0, 0) table.attach(self._hscroll, 1, 2, 4, 5, gtk.FILL | gtk.SHRINK, gtk.FILL, 0, 0) table.attach(self.menubar, 0, 3, 0, 1, gtk.FILL | gtk.SHRINK, gtk.FILL, 0, 0) table.attach(self.toolbar, 0, 3, 1, 2, gtk.FILL | gtk.SHRINK, gtk.FILL, 0, 0) table.attach(self.statusbar, 0, 3, 5, 6, gtk.FILL | gtk.SHRINK, gtk.FILL, 0, 0) if prefs['default double page']: self.actiongroup.get_action('double_page').activate() if prefs['default fullscreen'] or fullscreen: self.actiongroup.get_action('fullscreen').activate() if prefs['default manga mode']: self.actiongroup.get_action('manga_mode').activate() if prefs['default zoom mode'] == preferences.ZOOM_MODE_BEST: self.actiongroup.get_action('best_fit_mode').activate() elif prefs['default zoom mode'] == preferences.ZOOM_MODE_WIDTH: self.actiongroup.get_action('fit_width_mode').activate() elif prefs['default zoom mode'] == preferences.ZOOM_MODE_HEIGHT: self.actiongroup.get_action('fit_height_mode').activate() elif prefs['default zoom mode'] == preferences.ZOOM_MODE_MANUAL: # This little ugly hack is to get the activate call on # 'fit_manual_mode' to actually create an event (and callback). # Since manual mode is the default selected radio button action # it won't send an event if we activate it when it is already # the selected one. self.actiongroup.get_action('best_fit_mode').activate() self.actiongroup.get_action('fit_manual_mode').activate() if prefs['show toolbar']: prefs['show toolbar'] = False self.actiongroup.get_action('toolbar').activate() if prefs['show menubar']: prefs['show menubar'] = False self.actiongroup.get_action('menubar').activate() if prefs['show statusbar']: prefs['show statusbar'] = False self.actiongroup.get_action('statusbar').activate() if prefs['show scrollbar']: prefs['show scrollbar'] = False self.actiongroup.get_action('scrollbar').activate() if prefs['show thumbnails']: prefs['show thumbnails'] = False self.actiongroup.get_action('thumbnails').activate() if prefs['hide all']: prefs['hide all'] = False self.actiongroup.get_action('hide all').activate() if prefs['keep transformation']: prefs['keep transformation'] = False self.actiongroup.get_action('keep_transformation').activate() else: prefs['rotation'] = 0 prefs['vertical flip'] = False prefs['horizontal flip'] = False prefs['animate'] = animate_gifs self.add(table) table.show() self._main_layout.show() self._display_active_widgets() self._main_layout.set_events(gtk.gdk.BUTTON1_MOTION_MASK | gtk.gdk.BUTTON2_MOTION_MASK | gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.POINTER_MOTION_MASK) self._main_layout.drag_dest_set( gtk.DEST_DEFAULT_ALL, [('text/uri-list', 0, 0)], gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE) self.connect('delete_event', self.terminate_program) self.connect('key_press_event', self._event_handler.key_press_event) self.connect('configure_event', self._event_handler.resize_event) self._main_layout.connect('button_release_event', self._event_handler.mouse_release_event) self._main_layout.connect('scroll_event', self._event_handler.scroll_wheel_event) self._main_layout.connect('button_press_event', self._event_handler.mouse_press_event) self._main_layout.connect('motion_notify_event', self._event_handler.mouse_move_event) self._main_layout.connect('drag_data_received', self._event_handler.drag_n_drop_event) self.ui_manager.set_sensitivities() self.show() if open_path is not None: self.file_handler.open_file(open_path, open_page) if show_library: self.actiongroup.get_action('library').activate()
def refreshFileHandler(self): self.filehandler = fh.FileHandler(self.dir, [".wav", ".aif", ".aiff", ".flac"])
import filehandler import config import bro import os import nfscopy print "IMDS Producer Module", print " by Masoud Mehrabi" if os.geteuid() != 0: print "You must run this as root!" exit() print "Setting Up Network File Server..." nfscopy.InitMount() print "Starting Network Analyzer..." bro.RunBro() print "Warming Up..." wm = pyinotify.WatchManager() mask = pyinotify.IN_CREATE | pyinotify.IN_CLOSE_WRITE handler = filehandler.FileHandler() notifier = pyinotify.Notifier(wm, handler) wdd = wm.add_watch(config.IMDS_EXTRACTOR_INSTALL_PATH + "extract_files", mask, rec=True) print "Starting to monitor extracted files..." notifier.loop()