예제 #1
0
파일: Gnotwify.py 프로젝트: pabluk/gnotwify
    def _load_config(self):
        """Load configuration settings for Gnotwify."""
        config = ConfigParser.ConfigParser()

        config.read(CONFIG_FILE)
        self.disable_libnotify = config.getboolean("main", "disable_libnotify")
        self.loglevel = config.get("main", "loglevel")
        self.logger.setLevel(LOG_LEVELS.get(self.loglevel, logging.INFO))
        self.interval = int(config.get("main", "interval"))
        self.username = config.get("main", "username")
        password = self._get_password_from_keyring()
        if password:
            self.password = password
        else:
            self.password = ""
예제 #2
0
파일: Gnotwify.py 프로젝트: pabluk/gnotwify
    def __init__(self, status_icon):

        self.messages = []
        self.disable_libnotify = False
        self.username = ""
        self.password = ""
        self.interval = 35
        self.last_id = None
        self.loglevel = "debug"
        self.logger = logging.getLogger(APP_NAME)
        self.logger.setLevel(LOG_LEVELS.get(self.loglevel, logging.INFO))
        self.dialog = None
        self.force_update = False

        if not os.path.exists(CONFIG_DIR):
            os.mkdir(CONFIG_DIR)

        if not os.path.exists(CONFIG_FILE):
            # Create a config file with default values
            self._save_config()

        if not os.path.exists(DATA_DIR):
            os.mkdir(DATA_DIR)

        if not os.path.exists(CACHE_DIR):
            os.mkdir(CACHE_DIR)

        Thread.__init__(self, name=SRV_NAME)
        self.logger.debug("Thread started")

        self._load_config()

        self.updates_locked = False
        self.status_icon = status_icon

        self.status_icon.set_from_file(os.path.join(CURRENT_DIR, "icons", "twitter-inactive.svg"))

        self.status_icon.connect("button-press-event", self.button_press)
        try:
            keybinder.bind("F12", self.key_press, self.status_icon)
        except KeyError:
            self.logger.error("Unable to use <F12>. Hotkey is already bound")

        status_icon.set_visible(True)