Ejemplo n.º 1
0
    def __init__(self, plugin, window):
        self._window = window
        self._plugin = plugin
        self.find_ui = None
        self.find_history = []
        self.replace_history = []
        self.file_type_history = []
        self.file_path_history = []
        self.current_search_pattern = ""
        self.current_replace_text = ""
        #self.current_file_pattern = ""
        #self.current_path = ""
        self.forwardFlg = True
        self.scopeFlg = 0
        '''
		self.result_highlight_tag = gtk.TextTag('result_highlight')
		self.result_highlight_tag.set_properties(foreground='yellow',background='red')
		self.result_highlight_tag.set_property('family', 'Serif')
		self.result_highlight_tag.set_property('size-points', 12)
		self.result_highlight_tag.set_property('weight', pango.WEIGHT_BOLD)
		self.result_highlight_tag.set_property('underline', pango.UNDERLINE_DOUBLE)
		self.result_highlight_tag.set_property('style', pango.STYLE_ITALIC)
		#'''

        configfile = os.path.join(os.path.dirname(__file__), "config.xml")
        self.config_manager = config_manager.ConfigManager(configfile)
        self.find_options = self.config_manager.load_configure('FindOption')
        self.config_manager.to_bool(self.find_options)

        self.find_dlg_setting = self.config_manager.load_configure('FindGUI')
        self.config_manager.to_bool(self.find_dlg_setting)

        self.shortcuts = self.config_manager.load_configure('Shortcut')
        self.result_highlight = self.config_manager.load_configure(
            'ResultDisplay')

        self.result_gui_settings = self.config_manager.load_configure(
            'ResultGUI')
        self.config_manager.to_bool(self.result_gui_settings)

        self.find_history = self.config_manager.load_list('FindHistory')
        self.replace_history = self.config_manager.load_list('ReplaceHistory')
        self.file_type_history = self.config_manager.load_list('FilterHistory')
        self.file_path_history = self.config_manager.load_list('PathHistory')

        self._results_view = FindResultView(window, self.result_gui_settings)
        self._window.get_bottom_panel().add_item(self._results_view,
                                                 _("Advanced Find/Replace"),
                                                 "gtk-find-and-replace")

        self.msgDialog = gtk.MessageDialog(
            self._window, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, None)

        # Insert menu items
        self._insert_menu()
Ejemplo n.º 2
0
def main():
    import config_manager, report
    config = config_manager.ConfigManager("heatpumpMonitor.ini")
    aT = ThresholdMonitor(config, report.Report(config))
    aT.gotQueryError()
    aT.gotQueryError()
    aT.gotQueryError()
    aT.check({"booster_dhw": 100, "booster_heating": 200})
    aT.check({"booster_dhw": 101, "booster_heating": 200})
    aT.check({"booster_dhw": 100, "booster_heating": 200})
Ejemplo n.º 3
0
    def testIterConfigurations(self):
        cm = config_manager.ConfigManager(self.logger)
        configs = [x for x in cm.iterConfigurations()]
        self.failUnlessEqual([x.path for x in configs],
                             [os.path.join(self.workDir, 'values.xml')])
        self.failUnlessEqual([x.value for x in configs], [None])

        config = configs[0]
        self.failUnlessEqual(config.value, None)
        self.failIf(os.path.exists(config.path))

        config.value = 'abc'
        self.failUnlessEqual(config.value, 'abc')
        self.failUnless(os.path.exists(config.path))
Ejemplo n.º 4
0
    def testApply(self):
        cm = config_manager.ConfigManager(self.logger)
        config = cm.iterConfigurations().next()

        self.setBinary(failed=False)
        retcode, stdout, stderr = cm.apply(config)
        self.failUnlessEqual(retcode, 0)
        self.failUnlessEqual(
            stdout, "-x %s\n" % config_manager.ConfigManager.ConfigFilePath)

        self.setBinary(failed=True)
        retcode, stdout, stderr = cm.apply(config)
        self.failUnlessEqual(retcode, 1)
        self.failUnlessEqual(
            stderr, "-x %s\n" % config_manager.ConfigManager.ConfigFilePath)
Ejemplo n.º 5
0
	def __init__(self, window):
		self._window = window
		views = self._window.get_views()
		for view in views:
			view.get_buffer().connect('mark-set', self.on_textbuffer_markset_event)
		self.active_tab_added_id = self._window.connect("tab-added", self.tab_added_action)
		
		configfile = os.path.join(os.path.dirname(__file__), "config.xml")
		self.config_manager = config_manager.ConfigManager(configfile)
		self.options = self.config_manager.load_configure('search_option')
		for key in self.options.keys():
			if self.options[key] == 'True':
				self.options[key] = True
			elif self.options[key] == 'False':
				self.options[key] = False
		self.smart_highlight = self.config_manager.load_configure('smart_highlight')
Ejemplo n.º 6
0
    def __init__(self, plugin, window):
        self._window = window
        self._plugin = plugin
        views = self._window.get_views()
        for view in views:
            view.get_buffer().connect('mark-set',
                                      self.on_textbuffer_markset_event)
        self.active_tab_added_id = self._window.connect(
            "tab-added", self.tab_added_action)

        configfile = os.path.join(os.path.dirname(__file__), "config.xml")
        self.config_manager = config_manager.ConfigManager(configfile)
        self.options = self.config_manager.load_configure('search_option')
        self.config_manager.to_bool(self.options)
        self.smart_highlight = self.config_manager.load_configure(
            'smart_highlight')

        self._insert_menu()
Ejemplo n.º 7
0
    def __init__(self, plugin, window):
        self._window = window
        self._plugin = plugin
        self.current_selection = ''
        self.start_iter = None
        self.end_iter = None
        self.vadj_value = 0
        views = self._window.get_views()
        for view in views:
            view.get_buffer().connect('mark-set',
                                      self.on_textbuffer_markset_event)
            view.get_vadjustment().connect(
                'value-changed', self.on_view_vadjustment_value_changed)
            #view.connect('button-press-event', self.on_view_button_press_event)
        self.active_tab_added_id = self._window.connect(
            "tab-added", self.tab_added_action)

        user_configfile = os.path.join(CONFIG_DIR, 'config.xml')
        if not os.path.exists(user_configfile):
            if not os.path.exists(os.path.dirname(user_configfile)):
                os.makedirs(os.path.dirname(user_configfile))
            shutil.copy2(
                os.path.dirname(__file__) + "/config/config.xml",
                os.path.dirname(user_configfile))
        configfile = user_configfile
        '''		
		user_configfile = os.path.join(os.path.expanduser('~/.local/share/gedit/plugins/' + 'smart_highlight'), 'config.xml')
		if os.path.exists(user_configfile):
			configfile = user_configfile
		else:	
			configfile = os.path.join(os.path.dirname(__file__), "config.xml")
		#'''
        self.config_manager = config_manager.ConfigManager(configfile)
        self.options = self.config_manager.load_configure('search_option')
        self.config_manager.to_bool(self.options)
        self.smart_highlight = self.config_manager.load_configure(
            'smart_highlight')

        self._insert_menu()
Ejemplo n.º 8
0
    def __init__(self, configfilename):
        self.client_email = None
        self.client_pass = None
        self.discordClient = None
        self.event_manager = None
        self.main_watcher = None
        self.game_servers = {}
        self.commandregex = re.compile(
            "(?s)^!(?P<command>\w+)\s*(?P<args>.*)?")
        self.commands = {}
        self.botMethods = ['start', 'stop',
                           'server_address']  # Bob: now I hate it even more...
        self.FAMDB_API_key = None
        self.FAMDB_app_id = None
        self.TS3_address = None
        self.TS3_port = None
        self.TS3_password = None

        # Logging
        logging.basicConfig(filename="log/FA_bot.log",
                            level=logging.DEBUG,
                            format="%(asctime)-15s %(message)s")
        logging.info("FAbot starting up")
        logging.info("Registering commands: ")
        for method in dir(self):
            if callable(getattr(self, method)):
                if method[:2] != '__' and method not in self.botMethods:
                    call = getattr(self, method)
                    call(None, None)
                    logging.info(method)

        logging.info("Full command list:")
        logging.info(self.commands)

        # Configuration file
        logging.info("Reading configuration")
        self.config = config_manager.ConfigManager(configfilename)
Ejemplo n.º 9
0
def update_config():
    cm = config_manager.ConfigManager()
    cm.set_default_config()
Ejemplo n.º 10
0
    try:
        img = Image.open(path_to_image)
        return img.format
    except IOError:
        print 'Not an image file or unreadable.'


ap = argparse.ArgumentParser()
ap.add_argument("-i",
                "--image",
                type=str,
                required=True,
                help='python script needs file name and extenion')
args = vars(ap.parse_args())

config = config_manager.ConfigManager()

id_format = args['image'].split('.')
unique_ID = id_format[0]
image_format = id_format[1]

image_location = config.image_path(
) + unique_ID + '/' + unique_ID + '.' + image_format

image_read = cv2.imread(image_location, cv2.IMREAD_COLOR)
gray_image = cv2.cvtColor(image_read, cv2.COLOR_BGR2GRAY)

resized_gray_image = cv2.resize(gray_image, (1000, 1000))

pytesseract.pytesseract.tesseract_cmd = config.tesseract()
Ejemplo n.º 11
0
 def _getConfigManager(self, env):
     return config_manager.ConfigManager(env.get_logger())
Ejemplo n.º 12
0
    def __init__(self, window, result_gui_settings):
        Gtk.HBox.__init__(self)
        self._window = window
        self.result_gui_settings = result_gui_settings

        # load color theme of results list
        user_formatfile = os.path.join(
            CONFIG_DIR,
            'theme/' + self.result_gui_settings['COLOR_THEME'] + '.xml')
        if not os.path.exists(user_formatfile):
            if not os.path.exists(os.path.dirname(user_formatfile)):
                os.makedirs(os.path.dirname(user_formatfile))
            shutil.copy2(
                os.path.dirname(__file__) + "/config/theme/default.xml",
                os.path.dirname(user_formatfile))
        #print os.path.dirname(user_formatfile)
        format_file = user_formatfile
        #print format_file

        self.result_format = config_manager.ConfigManager(
            format_file).load_configure('result_format')
        config_manager.ConfigManager(format_file).to_bool(self.result_format)

        # initialize find result treeview
        self.findResultTreeview = Gtk.TreeView()
        resultsCellRendererText = Gtk.CellRendererText()
        if self.result_format['BACKGROUND']:
            resultsCellRendererText.set_property(
                'cell-background', self.result_format['BACKGROUND'])
        resultsCellRendererText.set_property('font',
                                             self.result_format['RESULT_FONT'])

        self.findResultTreeview.append_column(
            Gtk.TreeViewColumn("line", resultsCellRendererText, markup=1))
        self.findResultTreeview.append_column(
            Gtk.TreeViewColumn("content", resultsCellRendererText, markup=2))
        #self.findResultTreeview.append_column(Gtk.TreeViewColumn("result_start", Gtk.CellRendererText(), text=4))
        #self.findResultTreeview.append_column(Gtk.TreeViewColumn("result_len", Gtk.CellRendererText(), text=5))
        self.findResultTreeview.append_column(
            Gtk.TreeViewColumn("uri", resultsCellRendererText, text=6))

        self.findResultTreeview.set_grid_lines(
            int(self.result_format['GRID_PATTERN'])
        )  # 0: None; 1: Horizontal; 2: Vertical; 3: Both
        self.findResultTreeview.set_headers_visible(
            self.result_format['SHOW_HEADERS'])

        try:
            column_num = self.findResultTreeview.get_n_columns()
        except:
            # For older gtk version.
            column_num = len(self.findResultTreeview.get_columns())
        if self.result_format['SHOW_HEADERS']:
            for i in range(0, column_num):
                self.findResultTreeview.get_column(i).set_resizable(True)
        else:
            for i in range(0, column_num):
                self.findResultTreeview.get_column(i).set_sizing(
                    1)  # 1=autosizing

        self.findResultTreeview.set_rules_hint(True)
        self.findResultTreemodel = Gtk.TreeStore(int, str, str, object, int,
                                                 int, str)
        self.findResultTreemodel.set_sort_column_id(0, Gtk.SortType.ASCENDING)
        self.findResultTreeview.connect(
            "cursor-changed", self.on_findResultTreeview_cursor_changed_action)
        self.findResultTreeview.connect(
            "button-press-event",
            self.on_findResultTreeview_button_press_action)
        self.findResultTreeview.set_model(self.findResultTreemodel)

        # initialize scrolled window
        scrollWindow = Gtk.ScrolledWindow()
        scrollWindow.set_policy(Gtk.PolicyType.AUTOMATIC,
                                Gtk.PolicyType.AUTOMATIC)
        scrollWindow.add(self.findResultTreeview)

        # put a separator
        v_separator1 = Gtk.VSeparator()

        # initialize button box
        v_box = Gtk.VBox()
        v_buttonbox = Gtk.VButtonBox()
        v_buttonbox.set_layout(Gtk.ButtonBoxStyle.END)
        v_buttonbox.set_spacing(5)
        v_buttonbox.set_homogeneous(True)
        self.selectNextButton = Gtk.Button(_("Next"))
        self.selectNextButton.set_no_show_all(True)
        self.selectNextButton.connect("clicked",
                                      self.on_selectNextButton_clicked_action)
        self.expandAllButton = Gtk.Button(_("Expand All"))
        self.expandAllButton.set_no_show_all(True)
        self.expandAllButton.connect("clicked",
                                     self.on_expandAllButton_clicked_action)
        self.collapseAllButton = Gtk.Button(_("Collapse All"))
        self.collapseAllButton.set_no_show_all(True)
        self.collapseAllButton.connect(
            "clicked", self.on_collapseAllButton_clicked_action)
        self.clearHighlightButton = Gtk.Button(_("Clear Highlight"))
        self.clearHighlightButton.set_no_show_all(True)
        self.clearHighlightButton.connect(
            "clicked", self.on_clearHightlightButton_clicked_action)
        self.clearButton = Gtk.Button(_("Clear"))
        self.clearButton.set_no_show_all(True)
        self.clearButton.connect("clicked", self.on_clearButton_clicked_action)
        self.stopButton = Gtk.Button(_("Stop"))
        self.stopButton.set_no_show_all(True)
        self.stopButton.connect("clicked", self.on_stopButton_clicked_action)
        self.stopButton.set_sensitive(False)

        v_buttonbox.pack_start(self.selectNextButton, False, False, 5)
        v_buttonbox.pack_start(self.expandAllButton, False, False, 5)
        v_buttonbox.pack_start(self.collapseAllButton, False, False, 5)
        v_buttonbox.pack_start(self.clearHighlightButton, False, False, 5)
        v_buttonbox.pack_start(self.clearButton, False, False, 5)
        v_buttonbox.pack_start(self.stopButton, False, False, 5)
        v_box.pack_end(v_buttonbox, False, False, 5)

        #self._status = Gtk.Label()
        #self._status.set_text('test')
        #self._status.hide()
        #v_box.pack_end(self._status, False)

        self.pack_start(scrollWindow, True, True, 5)
        self.pack_start(v_separator1, False, False, 0)
        self.pack_start(v_box, False, False, 5)

        self.show_all()

        #initialize context menu
        self.contextMenu = Gtk.Menu()
        self.expandAllItem = Gtk.MenuItem.new_with_label(_('Expand All'))
        self.collapseAllItem = Gtk.MenuItem.new_with_label(_('Collapse All'))
        self.clearHighlightItem = Gtk.MenuItem.new_with_label(
            _('Clear Highlight'))
        self.clearItem = Gtk.MenuItem.new_with_label(_('Clear'))
        self.stopItem = Gtk.MenuItem.new_with_label(_('Stop'))
        self.stopItem.set_sensitive(False)
        self.markupItem = Gtk.MenuItem.new_with_label(_('Markup'))

        self.contextMenu.append(self.expandAllItem)
        self.contextMenu.append(self.collapseAllItem)
        self.contextMenu.append(self.clearHighlightItem)
        self.contextMenu.append(self.clearItem)
        self.contextMenu.append(self.stopItem)
        self.contextMenu.append(self.markupItem)

        self.expandAllItem.connect('activate', self.on_expandAllItem_activate)
        self.collapseAllItem.connect('activate',
                                     self.on_collapseAllItem_activate)
        self.clearHighlightItem.connect('activate',
                                        self.on_clearHighlightItem_activate)
        self.clearItem.connect('activate', self.on_clearItem_activate)
        self.stopItem.connect('activate', self.on_stopItem_activate)
        self.markupItem.connect('activate', self.on_markupItem_activate)

        self.expandAllItem.show()
        self.collapseAllItem.show()
        self.clearHighlightItem.show()
        self.clearItem.show()
        self.stopItem.show()
        #self.markupItem.show()

        self.contextMenu.append(Gtk.SeparatorMenuItem())

        self.showButtonsItem = Gtk.MenuItem.new_with_label(_('Show Buttons'))
        self.contextMenu.append(self.showButtonsItem)
        self.showButtonsItem.show()

        self.showButtonsSubmenu = Gtk.Menu()
        self.showNextButtonItem = Gtk.CheckMenuItem.new_with_label(_('Next'))
        self.showExpandAllButtonItem = Gtk.CheckMenuItem.new_with_label(
            _('Expand All'))
        self.showCollapseAllButtonItem = Gtk.CheckMenuItem.new_with_label(
            _('Collapse All'))
        self.showClearHighlightButtonItem = Gtk.CheckMenuItem.new_with_label(
            _('Clear Highlight'))
        self.showClearButtonItem = Gtk.CheckMenuItem.new_with_label(_('Clear'))
        self.showStopButtonItem = Gtk.CheckMenuItem.new_with_label(_('Stop'))

        self.showButtonsSubmenu.append(self.showNextButtonItem)
        self.showButtonsSubmenu.append(self.showExpandAllButtonItem)
        self.showButtonsSubmenu.append(self.showCollapseAllButtonItem)
        self.showButtonsSubmenu.append(self.showClearHighlightButtonItem)
        self.showButtonsSubmenu.append(self.showClearButtonItem)
        self.showButtonsSubmenu.append(self.showStopButtonItem)

        self.showNextButtonItem.connect('activate',
                                        self.on_showNextButtonItem_activate)
        self.showExpandAllButtonItem.connect(
            'activate', self.on_showExpandAllButtonItem_activate)
        self.showCollapseAllButtonItem.connect(
            'activate', self.on_showCollapseAllButtonItem_activate)
        self.showClearHighlightButtonItem.connect(
            'activate', self.on_showClearHighlightButtonItem_activate)
        self.showClearButtonItem.connect('activate',
                                         self.on_showClearButtonItem_activate)
        self.showStopButtonItem.connect('activate',
                                        self.on_showStopButtonItem_activate)

        self.showNextButtonItem.show()
        self.showExpandAllButtonItem.show()
        self.showCollapseAllButtonItem.show()
        self.showClearHighlightButtonItem.show()
        self.showClearButtonItem.show()
        self.showStopButtonItem.show()

        self.showButtonsItem.set_submenu(self.showButtonsSubmenu)

        self.show_buttons()
Ejemplo n.º 13
0
import config_manager


# Find similar setting of bits
def find_sim_bits(nbits):
    l_case_o1 = []
    for case in config["wanted_outputs"]:
        if config["wanted_outputs"][case] == 1:
            l_case_o1.append(case)
    print(l_case_o1)

    obj = l_case_o1[0]
    for i in range(0, len(obj)):
        counter = 0
        for case in l_case_o1[1:]:
            if obj[i] == case[i]:
                counter += 1
                print(case)
        print(i, "| ", obj[i], " : ", counter)


config = config_manager.ConfigManager(
    "config_file_4_conversed.json").get_config()
find_sim_bits(config["inputs"])
Ejemplo n.º 14
0
def main():
    global config
    config = config_manager.ConfigManager()
    deamon.startstop(config.getLogFile(), pidfile=config.getPidFile())
    doMonitor()
Ejemplo n.º 15
0
    def __init__(self, plugin, window):
        self._window = window
        self._plugin = plugin
        self.find_ui = None
        self.find_history = []
        self.replace_history = []
        self.filter_history = []
        self.path_history = []
        self.find_bookmarks = []
        self.replace_bookmarks = []
        self.filter_bookmarks = []
        self.path_bookmarks = []
        self.current_search_pattern = ""
        self.current_replace_text = ""
        self.current_file_pattern = "*"
        #self.current_path = ""
        self.forwardFlg = True
        self.scopeFlg = 0
        '''
		self.result_highlight_tag = Gtk.TextTag('result_highlight')
		self.result_highlight_tag.set_properties(foreground='yellow',background='red')
		self.result_highlight_tag.set_property('family', 'Serif')
		self.result_highlight_tag.set_property('size-points', 12)
		self.result_highlight_tag.set_property('weight', pango.WEIGHT_BOLD)
		self.result_highlight_tag.set_property('underline', pango.UNDERLINE_DOUBLE)
		self.result_highlight_tag.set_property('style', pango.STYLE_ITALIC)
		#'''

        user_configfile = os.path.join(CONFIG_DIR, 'config.xml')
        if not os.path.exists(user_configfile):
            if not os.path.exists(os.path.dirname(user_configfile)):
                os.makedirs(os.path.dirname(user_configfile))
            shutil.copy2(
                os.path.dirname(__file__) + "/config/config.xml",
                os.path.dirname(user_configfile))
        #print os.path.dirname(user_configfile)
        configfile = user_configfile
        #print configfile

        self.config_manager = config_manager.ConfigManager(configfile)
        self.find_options = self.config_manager.load_configure('FindOption')
        self.config_manager.to_bool(self.find_options)

        self.find_dlg_setting = self.config_manager.load_configure('FindGUI')
        self.config_manager.to_bool(self.find_dlg_setting)

        self.shortcuts = self.config_manager.load_configure('Shortcut')
        self.result_highlight = self.config_manager.load_configure(
            'ResultDisplay')

        self.result_gui_settings = self.config_manager.load_configure(
            'ResultGUI')
        self.config_manager.to_bool(self.result_gui_settings)

        user_patterns = os.path.join(CONFIG_DIR, 'patterns.xml')
        if not os.path.exists(user_patterns):
            if not os.path.exists(os.path.dirname(user_patterns)):
                os.makedirs(os.path.dirname(user_patterns))
            shutil.copy2(
                os.path.dirname(__file__) + "/config/patterns.xml",
                os.path.dirname(user_patterns))
        #print os.path.dirname(user_patterns)
        patternsfile = user_patterns
        #print patternsfile

        self.patterns_manager = config_manager.ConfigManager(patternsfile)
        self.find_history = self.patterns_manager.load_list('FindHistory')
        self.replace_history = self.patterns_manager.load_list(
            'ReplaceHistory')
        self.filter_history = self.patterns_manager.load_list('FilterHistory')
        self.path_history = self.patterns_manager.load_list('PathHistory')
        self.find_bookmarks = self.patterns_manager.load_list('FindBookmark')
        self.replace_bookmarks = self.patterns_manager.load_list(
            'ReplaceBookmark')
        self.filter_bookmarks = self.patterns_manager.load_list(
            'FilterBookmark')
        self.path_bookmarks = self.patterns_manager.load_list('PathBookmark')

        self._results_view = FindResultView(window, self.result_gui_settings)
        icon = Gtk.Image.new_from_stock(Gtk.STOCK_FIND_AND_REPLACE,
                                        Gtk.IconSize.MENU)
        self._window.get_bottom_panel().add_item(self._results_view,
                                                 'AdvancedFindBottomPanel',
                                                 _("Advanced Find/Replace"),
                                                 icon)

        self.msgDialog = Gtk.MessageDialog(
            self._window,
            Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
            Gtk.MessageType.INFO, Gtk.ButtonsType.CLOSE, None)

        # Insert menu items
        self._insert_menu()
Ejemplo n.º 16
0
        opts, args = getopt.getopt(sys.argv[parsingStartingPoint:], 'c:hf')
    except getopt.error, msg:
        usage(msg)

    configFile = None
    doNotFork = False
    for o, a in opts:
        if o == '-h':
            print __doc__
            sys.exit()
        if o == '-c':
            configFile = a
        if o == '-f':
            doNotFork = True

    myConfigManager = config_manager.ConfigManager(configFile)
    # we instance it here so its before we go into the background
    myUniFiLab = UniFiLab(myConfigManager)

    # on non Windows Systems we go into the background
    if not doNotFork and sys.platform in ("linux2", "darwin"):
        daemon.startstop(myConfigManager.getErrorLogFile(),
                         pidfile=myConfigManager.getPidFile())

    # configure the logging
    _handler = logging.handlers.RotatingFileHandler(
        myConfigManager.getLogFile(), maxBytes=10 * 1024**2, backupCount=5)
    _handler.setFormatter(
        logging.Formatter("%(asctime)s - %(levelname)s - %(message)s"))
    log.addHandler(_handler)
Ejemplo n.º 17
0
def initialise(screenIO):
    configurationManager = config_manager.ConfigManager()
    configurationManager.load_config()
    screenIO.renderConfigMenu(configurationManager)
    configurationManager.set_types()
    return configurationManager.config
Ejemplo n.º 18
0
def main():
    import config_manager
    myReport = Report(config_manager.ConfigManager("heatpumpMonitor.ini"))
    myReport.counterIncreased(name = "testX", reference = 123, actual = 124)
Ejemplo n.º 19
0
	def __init__(self, window, show_button_option):
		gtk.HBox.__init__(self)
		self._window = window
		self.show_button_option = show_button_option
		
		# initialize find result treeview
		self.findResultTreeview = gtk.TreeView()
		self.findResultTreeview.append_column(gtk.TreeViewColumn("line", gtk.CellRendererText(), markup=1))
		self.findResultTreeview.append_column(gtk.TreeViewColumn("content", gtk.CellRendererText(), markup=2))
		#self.findResultTreeview.append_column(gtk.TreeViewColumn("result_start", gtk.CellRendererText(), text=4))
		#self.findResultTreeview.append_column(gtk.TreeViewColumn("result_len", gtk.CellRendererText(), text=5))
		self.findResultTreeview.append_column(gtk.TreeViewColumn("uri", gtk.CellRendererText(), text=6))
		self.findResultTreeview.set_headers_visible(False)
		self.findResultTreeview.set_rules_hint(True)
		self.findResultTreemodel = gtk.TreeStore(int, str, str, object, int, int, str)
		self.findResultTreemodel.set_sort_column_id(0, gtk.SORT_ASCENDING)
		self.findResultTreeview.connect("cursor-changed", self.on_findResultTreeview_cursor_changed_action)
		self.findResultTreeview.connect("button-press-event", self.on_findResultTreeview_button_press_action)
		self.findResultTreeview.set_model(self.findResultTreemodel)

		# initialize scrolled window
		scrollWindow = gtk.ScrolledWindow()
		scrollWindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		scrollWindow.add(self.findResultTreeview)
		
		# put a separator
		v_separator1 = gtk.VSeparator()
		
		# initialize button box
		v_box = gtk.VBox()
		v_buttonbox = gtk.VButtonBox()
		v_buttonbox.set_layout(gtk.BUTTONBOX_END)
		v_buttonbox.set_spacing(5)
		self.selectNextButton = gtk.Button(_("Next"))
		self.selectNextButton.set_no_show_all(True)
		self.selectNextButton.connect("clicked", self.on_selectNextButton_clicked_action)
		self.expandAllButton = gtk.Button(_("Expand All"))
		self.expandAllButton.set_no_show_all(True)
		self.expandAllButton.connect("clicked", self.on_expandAllButton_clicked_action)
		self.collapseAllButton = gtk.Button(_("Collapse All"))
		self.collapseAllButton.set_no_show_all(True)
		self.collapseAllButton.connect("clicked", self.on_collapseAllButton_clicked_action)
		self.clearHighlightButton = gtk.Button(_("Clear Highlight"))
		self.clearHighlightButton.set_no_show_all(True)
		self.clearHighlightButton.connect("clicked", self.on_clearHightlightButton_clicked_action)
		self.clearButton = gtk.Button(_("Clear"))
		self.clearButton.set_no_show_all(True)
		self.clearButton.connect("clicked", self.on_clearButton_clicked_action)

		v_buttonbox.pack_start(self.selectNextButton, False, False, 5)
		v_buttonbox.pack_start(self.expandAllButton, False, False, 5)
		v_buttonbox.pack_start(self.collapseAllButton, False, False, 5)
		v_buttonbox.pack_start(self.clearHighlightButton, False, False, 5)
		v_buttonbox.pack_start(self.clearButton, False, False, 5)
		v_box.pack_end(v_buttonbox, False, False, 5)
		
		#self._status = gtk.Label()
		#self._status.set_text('test')
		#self._status.hide()
		#v_box.pack_end(self._status, False)
		
		self.pack_start(scrollWindow, True, True, 5)
		self.pack_start(v_separator1, False, False)
		self.pack_start(v_box, False, False, 5)
		
		self.show_all()
		
		#initialize context menu
		self.contextMenu = gtk.Menu()
		self.expandAllItem = gtk.MenuItem(_('Expand All'))
		self.collapseAllItem = gtk.MenuItem(_('Collapse All'))
		self.clearHighlightItem = gtk.MenuItem(_('Clear Highlight'))
		self.clearItem = gtk.MenuItem(_('Clear'))
		self.markupItem = gtk.MenuItem(_('Markup'))
		
		self.contextMenu.append(self.expandAllItem)
		self.contextMenu.append(self.collapseAllItem)
		self.contextMenu.append(self.clearHighlightItem)
		self.contextMenu.append(self.clearItem)
		self.contextMenu.append(self.markupItem)
		
		self.expandAllItem.connect('activate', self.on_expandAllItem_activate)
		self.collapseAllItem.connect('activate', self.on_collapseAllItem_activate)
		self.clearHighlightItem.connect('activate', self.on_clearHighlightItem_activate)
		self.clearItem.connect('activate', self.on_clearItem_activate)
		self.markupItem.connect('activate', self.on_markupItem_activate)

		self.expandAllItem.show()
		self.collapseAllItem.show()
		self.clearHighlightItem.show()
		self.clearItem.show()
		#self.markupItem.show()
		
		self.contextMenu.append(gtk.SeparatorMenuItem())
		
		self.showButtonsItem = gtk.MenuItem(_('Show Buttons'))
		self.contextMenu.append(self.showButtonsItem)
		self.showButtonsItem.show()
		
		self.showButtonsSubmenu = gtk.Menu()
		self.showNextButtonItem = gtk.CheckMenuItem(_('Next'))
		self.showExpandAllButtonItem = gtk.CheckMenuItem(_('Expand All'))
		self.showCollapseAllButtonItem = gtk.CheckMenuItem(_('Collapse All'))
		self.showClearHighlightButtonItem = gtk.CheckMenuItem(_('Clear Highlight'))
		self.showClearButtonItem = gtk.CheckMenuItem(_('Clear'))
		
		self.showButtonsSubmenu.append(self.showNextButtonItem)
		self.showButtonsSubmenu.append(self.showExpandAllButtonItem)
		self.showButtonsSubmenu.append(self.showCollapseAllButtonItem)
		self.showButtonsSubmenu.append(self.showClearHighlightButtonItem)
		self.showButtonsSubmenu.append(self.showClearButtonItem)
		
		self.showNextButtonItem.connect('activate', self.on_showNextButtonItem_activate)
		self.showExpandAllButtonItem.connect('activate', self.on_showExpandAllButtonItem_activate)
		self.showCollapseAllButtonItem.connect('activate', self.on_showCollapseAllButtonItem_activate)
		self.showClearHighlightButtonItem.connect('activate', self.on_showClearHighlightButtonItem_activate)
		self.showClearButtonItem.connect('activate', self.on_showClearButtonItem_activate)
		
		self.showNextButtonItem.show()
		self.showExpandAllButtonItem.show()
		self.showCollapseAllButtonItem.show()
		self.showClearHighlightButtonItem.show()
		self.showClearButtonItem.show()
		
		self.showButtonsItem.set_submenu(self.showButtonsSubmenu)
		
		self.show_buttons()

		format_file = os.path.join(os.path.dirname(__file__), "result_format.xml")
		self.result_format = config_manager.ConfigManager(format_file).load_configure('result_format')
Ejemplo n.º 20
0
import config_manager
test = config_manager.ConfigManager("config_file_7_conversed.json")
test.parse_x_logic("x_logic_9_G0.json", "G0")

# test_dict = {"xx":2, "xxxx":1}
# sorted(test_dict, key=len, reverse=True)
# print(sorted(test_dict, key=len, reverse=True))
#