Beispiel #1
0
    def __init__(self, specto, id, values):
        watch_values = [("username", spectlib.config.String(True)),
                        ("password", spectlib.config.String(True)),
                        ("label", spectlib.config.String(False))]
        url = "https://mail.google.com"
        self.standard_open_command = spectlib.util.return_webpage(url)

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)

        if self.open_command == self.standard_open_command: #check if google apps url has to be used
            if "@" in self.username and not "@gmail.com" and not "@googlemail.com" in self.username:
                url = "http://mail.google.com/a/" + self.username.split("@")[1]  # We use mail.google.com instead of gmail.com because of the trademark issue in Germany
                self.standard_open_command = spectlib.util.return_webpage(url)
                self.open_command = self.standard_open_command

        self.use_network = True
        self.icon = icon
        self.type_desc = type_desc
        self.cache_file = os.path.join(self.specto.CACHE_DIR, "gmail" + self.username + ".cache")

        #watch specific values
        self.oldMsg = 0
        self.newMsg = 0
        self.mail_info = Email_collection()

        self.read_cache_file()
Beispiel #2
0
    def __init__(self, specto, id, values):

        watch_values = [("receivedimmsg_", spectlib.config.Boolean(False)),
                        ("receivedchatmsg_", spectlib.config.Boolean(False)),
                        ("buddystatuschanged_",
                         spectlib.config.Boolean(False)),
                        ("buddysignedon_", spectlib.config.Boolean(False)),
                        ("buddysignedoff_", spectlib.config.Boolean(False))]

        self.icon = icon
        self.standard_open_command = ''
        self.type_desc = type_desc

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)

        self.dbus = True
        self.message = ""
        self.extra_info = ""
        # Use the dbus interface we saw in dbus-notify
        self.dbus_interface = "im.pidgin.purple.PurpleInterface"
        self.dbus_path = "/im/pidgin/purple/PurpleObject"
        self.dbus_name = "im.pidgin.purple.PurpleService"

        self.signals = {
            "ReceivedImMsg": self.ReceivedImMsg,
            "ReceivedChatMsg": self.ReceivedChatMsg,
            "BuddyStatusChanged": self.BuddyStatusChanged,
            "BuddySignedOn": self.BuddySignedOn,
            "BuddySignedOff": self.BuddySignedOff,
        }
Beispiel #3
0
    def __init__(self, specto, id, values):

        watch_values = [("folder", spectlib.config.String(True))]

        self.icon = icon
        self.standard_open_command = 'xdg-open %s' % values['folder']
        self.type_desc = type_desc

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)

        self.use_network = True
        self.repositoy_info = []
        self.remote_branch_label = ""
        self.local_changes = []
        self.remote_changes = []

        # Kind of changes to check for, and there are two copies
        # so it is possible to make different checks for local/remote
        self.local_check_kinds = [pysvn.wc_status_kind.modified,\
                                  pysvn.wc_status_kind.added,\
                                  pysvn.wc_status_kind.deleted,\
                                  pysvn.wc_status_kind.replaced,\
                                  pysvn.wc_status_kind.merged,\
                                 ]
        self.remote_check_kinds = [pysvn.wc_status_kind.modified,\
                                   pysvn.wc_status_kind.added,\
                                   pysvn.wc_status_kind.deleted,\
                                   pysvn.wc_status_kind.replaced,\
                                   pysvn.wc_status_kind.merged,\
                                  ]

        #Init the pysvn client, and error style
        self.svn_client = pysvn.Client()
        self.svn_client.exception_style = 0
Beispiel #4
0
    def check(self):
        """ Check for new news on your greader account. """
        try:
            self.newMsg = 0
            self.unreadMsg = 0
            greader = Greader(self.username, self.password, "specto")
            auth = greader.login()
            feed_db = greader.get_unread_items(auth)
            for feed in feed_db:
                self.unreadMsg += feed.messages
                if feed.messages > 0 and self.news_info.add(feed):
                    self.actually_changed = True
                    self.newMsg += feed.messages
            if self.unreadMsg == 0:#no unread items, we need to clear the watch
                self.mark_as_read()
                self.news_info = Feed_collection()
            else:
                if self.unreadMsg == 1000:
                    self.or_more = _(" or more")
                
            self.write_cache_file()

        except:
            self.set_error()

        Watch.timer_update(self)
Beispiel #5
0
    def check(self):
        """ Check for new news on your greader account. """
        try:
            self.newMsg = 0
            self.unreadMsg = 0
            greader = Greader(self.username, self.password, "specto")
            auth = greader.login()
            feed_db = greader.get_unread_items(auth)
            for feed in feed_db:
                self.unreadMsg += feed.messages
                if feed.messages > 0 and self.news_info.add(feed):
                    self.actually_changed = True
                    self.newMsg += feed.messages
            if self.unreadMsg == 0:  #no unread items, we need to clear the watch
                self.mark_as_read()
                self.news_info = Feed_collection()
            else:
                if self.unreadMsg == 1000:
                    self.or_more = _(" or more")

            self.write_cache_file()

        except:
            self.set_error()

        Watch.timer_update(self)
Beispiel #6
0
    def __init__(self, specto, id, values):

        watch_values = [("username", spectlib.config.String(True)),
                        ("password", spectlib.config.String(True)),
                        ("host", spectlib.config.String(True)),
                        ("ssl", spectlib.config.Boolean(False)),
                        ("port", spectlib.config.Integer(False))]

        self.standard_open_command = spectlib.util.open_gconf_application(
            "/desktop/gnome/url-handlers/mailto")

        Watch.__init__(self, specto, id, values, watch_values)

        self.type_desc = type_desc
        self.use_network = True
        self.icon = icon
        self.cache_file = os.path.join(
            self.specto.CACHE_DIR,
            "pop3" + self.host + self.username + ".cache")

        self.newMsg = 0
        self.unreadMsg = 0
        self.mail_id = []
        self.mail_info = Email_collection()

        self.read_cache_file()
Beispiel #7
0
    def __init__(self, specto, id, values):

        watch_values = []
        self.icon = icon
        self.current_song = ""
        self.standard_open_command = 'amarok'
        self.type_desc = type_desc

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)
        
        self.dbus = True
        self.message = ""
        self.extra_info = ""
        # Use the dbus interface we saw in dbus-notify
        self.dbus_interface = "org.kde.Amarok"
        self.dbus_path = "/org/kde/Amarok"
        self.dbus_name = "org.kde.Amarok"

        self.signals = {"TrackChange": self.playingUriChanged}
        
        
	def playingUriChanged(self, title, artist, album, track):
  			self.message = "%s - %s\nTrack: %s" %(artist, album, track)
  			self.current_song = "%s - %s" % (artist, track)
        self.watch_changed()
Beispiel #8
0
    def update(self, lock):
        """ See if a file was modified or created. """
        self.error = False
        self.specto.mark_watch_busy(True, self.id)
        self.specto.logger.log(
            _("Updating watch: \"%s\"") % self.name, "info", self.__class__)

        try:
            process = self.check_process()
            if self.running and process == False:
                self.running = False
                self.updated = True
                self.actually_updated = True
            elif self.running == False and process == True:
                self.running = True
                self.actually_updated = True
            else:
                self.actually_updated = False
        except:
            self.error = True
            self.specto.logger.log(
                _("Watch: \"%s\" has an error") % self.name, "error",
                self.__class__)

        self.specto.mark_watch_busy(False, self.id)
        Watch.update(self, lock)
Beispiel #9
0
 def update(self, lock):
     """ Check for new mails on your gmail account. """
     self.error = False
     self.specto.mark_watch_busy(True, self.id)
     self.specto.logger.log(_("Updating watch: \"%s\"") % self.name, "info", self.__class__)
     
     try:
         self.oldMsg = self.newMsg
         self.newMsg = 0
         SID = self.get_SID()
         f = file(self.cache_file , "w")
         f.write(str(self.get_reading_list(SID)))
         f.close()
         doc = minidom.parse(self.cache_file)
         rootNode = doc.documentElement
         attributes =[] 
         self.walk(rootNode, False, attributes)
         
         if self.oldMsg == 0 and self.newMsg == 0:#no unread messages, we need to clear the watch
             self.actually_updated=False
             self.specto.notifier.clear_watch("", self.id)
         if self.newMsg > 0:
             self.actually_updated=True
             if self.oldMsg == 0:
                 self.oldMsg = self.newMsg
     except:
         self.error = True
         self.specto.logger.log(_("Watch: \"%s\" has error: Error in processing cache file") % self.name, "error", self.__class__)
         
     self.specto.mark_watch_busy(False, self.id)
     Watch.update(self, lock)
Beispiel #10
0
    def check(self):
        """ See if a folder's contents were modified or created. """
        try:
            self.old_values = self.read_cache_file()
            mode = os.stat(self.folder)[ST_MODE]
            self.new_files = []
            if S_ISDIR(mode):
                self.get_dir(self.folder)
                self.update_cache_file(
                )  #write the new values to the cache file
                self.old_values = self.read_cache_file()  #read the new valeus
                self.get_removed_files()  #remove the files that were removed
                self.update_cache_file(
                )  #write the values (with the removed lines) to the cache file
            else:
                self.set_error(_('The watch is not set to a folder'))

            #first time don't mark as changed
            if self.first_time == True:
                self.actually_changed = False
                self.first_time = False
        except:
            self.set_error()

        Watch.timer_update(self)
Beispiel #11
0
    def update(self, lock):
        """ See if a socket was opened or closed. """
        self.error = False
        self.specto.mark_watch_busy(True, self.id)
        self.specto.logger.log(
            _("Updating watch: \"%s\"") % self.name, "info", self.__class__)

        try:
            established = self.check_port()
            if self.running and established == False:
                self.running = False
                self.actually_updated = True
            elif self.running == False and established == True:
                self.running = True
                self.actually_updated = True
            else:
                self.actually_updated = False
        except:
            self.error = True
            self.specto.logger.log(
                _("Watch: \"%s\" has an error") % self.name, "error",
                self.__class__)

        self.specto.mark_watch_busy(False, self.id)
        Watch.update(self, lock)
Beispiel #12
0
    def __init__(self, specto, id, values):

        watch_values = [("receivedimmsg_", spectlib.config.Boolean(False)),
                        ("receivedchatmsg_", spectlib.config.Boolean(False)),
                        ("buddystatuschanged_", spectlib.config.Boolean(False)),
                        ("buddysignedon_", spectlib.config.Boolean(False)),
                        ("buddysignedoff_", spectlib.config.Boolean(False))
                        ]

        self.icon = icon
        self.standard_open_command = ''
        self.type_desc = type_desc

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)
        
        self.dbus = True
        self.message = ""
        self.extra_info = ""
        # Use the dbus interface we saw in dbus-notify
        self.dbus_interface = "im.pidgin.purple.PurpleInterface"
        self.dbus_path = "/im/pidgin/purple/PurpleObject"
        self.dbus_name = "im.pidgin.purple.PurpleService"

        self.signals = {
            "ReceivedImMsg": self.ReceivedImMsg,
            "ReceivedChatMsg": self.ReceivedChatMsg,
            "BuddyStatusChanged": self.BuddyStatusChanged,
            "BuddySignedOn": self.BuddySignedOn,
            "BuddySignedOff": self.BuddySignedOff,            
             }
Beispiel #13
0
 def update(self, lock):
     """ Check for new mails on your gmail account. """
     self.error = False
     self.specto.mark_watch_busy(True, self.id)
     self.specto.logger.log(_("Updating watch: \"%s\"") % self.name, "info", self.__class__)
     
     try:
         s = GmailAtom(self.user, self.password)
         s.refreshInfo()
         self.oldMsg = s.getUnreadMsgCount()
         self.newMsg = 0
         if self.oldMsg == 0:#no unread messages, we need to clear the watch
             self.actually_updated=False
             self.specto.notifier.clear_watch("", self.id)
         else:
             i=0
             while i < self.oldMsg:
                 info = s.getMsgAuthorName(i) + s.getMsgTitle(i) + s.getMsgSummary(i) #create unique info
                 if info not in self.mail_info: #check if it is a new email or just unread
                     self.actually_updated=True
                     self.mail_info.append(info)
                     self.newMsg+=1
                 i+=1
     except:
         self.error = True
         self.specto.logger.log(_("Watch: \"%s\" has error: wrong username/password") % self.name, "error", self.__class__)
         
     self.specto.mark_watch_busy(False, self.id)
     Watch.update(self, lock)
Beispiel #14
0
    def __init__(self, specto, id, values):

        watch_values = [("folder", spectlib.config.String(True))]

        self.icon = icon
        self.standard_open_command = 'xdg-open %s' % values['folder']
        self.type_desc = type_desc

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)

        self.use_network = True
        self.repositoy_info = []
        self.remote_branch_label = ""
        self.local_changes = []
        self.remote_changes = []
        
        # Kind of changes to check for, and there are two copies
        # so it is possible to make different checks for local/remote
        self.local_check_kinds = [pysvn.wc_status_kind.modified,\
                                  pysvn.wc_status_kind.added,\
                                  pysvn.wc_status_kind.deleted,\
                                  pysvn.wc_status_kind.replaced,\
                                  pysvn.wc_status_kind.merged,\
                                 ]
        self.remote_check_kinds = [pysvn.wc_status_kind.modified,\
                                   pysvn.wc_status_kind.added,\
                                   pysvn.wc_status_kind.deleted,\
                                   pysvn.wc_status_kind.replaced,\
                                   pysvn.wc_status_kind.merged,\
                                  ]
        
        #Init the pysvn client, and error style
        self.svn_client = pysvn.Client()
        self.svn_client.exception_style = 0
Beispiel #15
0
    def __init__(self, specto, id, values):

        watch_values = []
        self.icon = icon
        self.current_song = ""
        self.standard_open_command = 'amarok'
        self.type_desc = type_desc

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)

        self.dbus = True
        self.message = ""
        self.extra_info = ""
        # Use the dbus interface we saw in dbus-notify
        self.dbus_interface = "org.kde.Amarok"
        self.dbus_path = "/org/kde/Amarok"
        self.dbus_name = "org.kde.Amarok"

        self.signals = {"TrackChange": self.playingUriChanged}

        def playingUriChanged(self, title, artist, album, track):
            self.message = "%s - %s\nTrack: %s" % (artist, album, track)
            self.current_song = "%s - %s" % (artist, track)

        self.watch_changed()
Beispiel #16
0
    def update(self, lock):
        """ Check for new mails on your gmail account. """
        self.error = False
        self.specto.mark_watch_busy(True, self.id)
        self.specto.logger.log(
            _("Updating watch: \"%s\"") % self.name, "info", self.__class__)

        try:
            s = GmailAtom(self.user, self.password)
            s.refreshInfo()
            self.oldMsg = s.getUnreadMsgCount()
            self.newMsg = 0
            if self.oldMsg == 0:  #no unread messages, we need to clear the watch
                self.actually_updated = False
                self.specto.notifier.clear_watch("", self.id)
            else:
                i = 0
                while i < self.oldMsg:
                    info = s.getMsgAuthorName(i) + s.getMsgTitle(
                        i) + s.getMsgSummary(i)  #create unique info
                    if info not in self.mail_info:  #check if it is a new email or just unread
                        self.actually_updated = True
                        self.mail_info.append(info)
                        self.newMsg += 1
                    i += 1
        except:
            self.error = True
            self.specto.logger.log(
                _("Watch: \"%s\" has error: wrong username/password") %
                self.name, "error", self.__class__)

        self.specto.mark_watch_busy(False, self.id)
        Watch.update(self, lock)
Beispiel #17
0
 def update(self, lock):
     """ See if a file was modified or created. """
     self.error = False
     self.updated = False
     self.specto.mark_watch_busy(True, self.id)
     self.specto.logger.log(_("Updating watch: \"%s\"") % self.name, "info", self.__class__)
     
     try:
         self.get_cache_file()
         self.old_values = self.read_cache_file()
         mode = os.stat(self.file)[ST_MODE]
         self.new_files = []
         if S_ISDIR(mode):
             self.get_dir(self.file)
             self.update_cache_file()#write the new values to the cache file
             self.old_values = self.read_cache_file() #read the new valeus
             self.get_removed_files() #remove the files that were removed
             self.update_cache_file()#write the values (with the removed lines) to the cache file
         else:
             self.get_file(self.file)
             self.update_cache_file()
             
         #first time don't mark as updated
         if self.first_time == True:
             self.updated = False
             self.first_time = False            
     except:
         self.error = True
         self.specto.logger.log(_("Watch: \"%s\" has an error") % self.name, "error", self.__class__)
     
     self.specto.mark_watch_busy(False, self.id)
     self.actually_updated = self.updated
     Watch.update(self, lock)
Beispiel #18
0
    def check(self):
        """ See if a there are new facebook items. """
        try:
            self.updates = {
                'message': [],
                'notification': [],
                'request': [],
                'wall': []
            }
            #message
            facebook = Facebook(self.email, self.password)
            if facebook.connect():
                self.messages = facebook.get_messages()
                for message in self.messages:
                    if message.sender + ": " + message.message not in self.previous_messages:
                        self.updates['message'].append(message.sender + ": " +
                                                       message.message)
                        self.actually_changed = True
                        self.previous_messages.append(message.sender + ": " +
                                                      message.message)

                # Facebook notifications
                self.notifications = facebook.get_notifications()
                for notification in self.notifications:
                    if notification.notification not in self.previous_notifications:
                        self.updates['notification'].append(
                            notification.notification)
                        self.actually_changed = True
                        self.previous_notifications.append(
                            notification.notification)

                # Requests
                self.requests = facebook.get_requests()
                for request in self.requests:
                    if request.request not in self.previous_requests:
                        self.updates['request'].append(request.request)
                        self.actually_changed = True
                        self.previous_requests.append(request.request)

                # Wall posts
                self.wall = facebook.get_wall()
                for w in self.wall:
                    if w.poster + ": " + w.post not in self.previous_wall:
                        self.updates['wall'].append(w.poster + ": " + w.post)
                        self.actually_changed = True
                        self.previous_wall.append(w.poster + ": " + w.post)

                self.write_cache_file()
                if len(self.messages) == 0 and len(
                        self.notifications) == 0 and len(
                            self.requests) == 0 and len(self.wall) == 0:
                    self.mark_as_read()
            else:
                self.set_error((_("Wrong username/password")))
        except:
            self.set_error()

        Watch.timer_update(self)
Beispiel #19
0
 def __init__(self, refresh, port, specto, id,  name = _("Unknown Process Watch")):
     Watch.__init__(self, specto)
     self.name = name
     self.refresh = refresh
     self.port = port
     self.id = id
     self.error = False
     self.actually_updated=False
     self.running = self.check_port()
Beispiel #20
0
 def __init__(self, specto, name, refresh, url, id, error_margin):
     Watch.__init__(self, specto) #init superclass
     self.refresh = refresh
     self.id = id
     self.url_ = url
     if self.url_ == "":
         self.specto.logger.log(_("Watch: \"%s\" has error: empty url") % self.error, "error", self.__class__)
     self.name = name
     self.error_margin = error_margin#the amount in percent (as a float) of what the filesize must change to consider the page changed
     self.error = False
Beispiel #21
0
 def __init__(self, refresh, host, username, password, ssl, specto, id, name = _("Unknown Mail Watch")):
     Watch.__init__(self, specto)
     self.name = name
     self.refresh = refresh
     self.host = host
     self.user = username
     self.password = password
     self.id = id
     self.error = False
     self.ssl = ssl
Beispiel #22
0
 def __init__(self, refresh, file, mode, specto, id,  name = _("Unknown File Watch")):
     Watch.__init__(self, specto)
     self.name = name
     self.refresh = refresh
     self.file = file
     self.mode = mode
     self.id = id
     self.error = False
     self.first_time = False
     self.actually_updated = False
Beispiel #23
0
 def __init__(self, refresh, username, password, specto, id,  name = _("Unknown Mail Watch")):
     Watch.__init__(self, specto)
     self.name = name
     self.refresh = refresh
     if "@" not in username:
         self.user = username + "@gmail.com"
     else:
         self.user = username
     self.password = password
     self.id = id
     self.error = False
Beispiel #24
0
 def check(self):
     """ Check if a new song is played on last.fm. """
     try:
         self.lastfm_ = LastFM(self.username)
         song = self.lastfm_.updateData()
         if song != self.previous_song:
             self.previous_song = song
             self.actually_changed = True
     except:
         self.set_error()
     Watch.timer_update(self)
Beispiel #25
0
    def __init__(self, specto, id, values):
        watch_values = [("port", spectlib.config.Integer(True))]

        self.icon = icon
        self.standard_open_command = ''
        self.type_desc = type_desc
        self.status = ""

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)

        self.running = self.check_port()
Beispiel #26
0
    def __init__(self, specto, id, values):
        watch_values = [("port", spectlib.config.Integer(True))]

        self.icon = icon
        self.standard_open_command = ''
        self.type_desc = type_desc
        self.status = ""

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)

        self.running = self.check_port()
Beispiel #27
0
    def __init__(self, specto, id, values):
        watch_values = [("username", spectlib.config.String(True))]
        self.standard_open_command = ""     

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)

        self.use_network = True
        self.icon = icon
        self.type_desc = type_desc
        self.extra_information = ""
        self.previous_song = ""
Beispiel #28
0
 def __init__(self, specto, name, refresh, url, id, error_margin):
     Watch.__init__(self, specto)  #init superclass
     self.refresh = refresh
     self.id = id
     self.url_ = url
     if self.url_ == "":
         self.specto.logger.log(
             _("Watch: \"%s\" has error: empty url") % self.error, "error",
             self.__class__)
     self.name = name
     self.error_margin = error_margin  #the amount in percent (as a float) of what the filesize must change to consider the page changed
     self.error = False
Beispiel #29
0
    def __init__(self, specto, id, values):
        watch_values = [("file", String(True))]

        self.icon = icon
        self.open_command = ''
        self.type_desc = type_desc
        self.standard_open_command = "xdg-open '%s'" % values['file']

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)

        self.cache_file = os.path.join(self.specto.CACHE_DIR, "file" + self.file.replace("/", "_") + ".cache")
        self.first_time = False
Beispiel #30
0
    def __init__(self, specto, id, values):

        watch_values = [("process", spectlib.config.String(True))]

        self.icon = icon
        self.standard_open_command = values['process']
        self.type_desc = type_desc
        self.status = ""

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)

        self.running_initially = self.check_process()
Beispiel #31
0
    def __init__(self, specto, id, values):

        watch_values = [("process", spectlib.config.String(True))]

        self.icon = icon
        self.standard_open_command = values['process']
        self.type_desc = type_desc
        self.status = ""

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)

        self.running_initially = self.check_process()
Beispiel #32
0
 def __init__(self,
              refresh,
              port,
              specto,
              id,
              name=_("Unknown Process Watch")):
     Watch.__init__(self, specto)
     self.name = name
     self.refresh = refresh
     self.port = port
     self.id = id
     self.error = False
     self.actually_updated = False
     self.running = self.check_port()
Beispiel #33
0
 def check(self):
     """ Check for new mails on your pop3 account. """
     try:
         if self.ssl == True:
             if self.port != -1:
                 try:
                     s = poplib.POP3_SSL(self.host, self.port)
                 except:
                     self.set_error()
                     Watch.timer_update(self)
                     return ""
             else:
                 try:
                     s = poplib.POP3_SSL(self.host)
                 except:
                     self.set_error()
                     Watch.timer_update(self)
                     return ""
         else:
             if self.port != -1:
                 try:
                     s = poplib.POP3(self.host, self.port)
                 except:
                     self.set_error()
                     Watch.timer_update(self)
                     return ""
             else:
                 try:
                     s = poplib.POP3(self.host)
                 except:
                     self.set_error()
                     Watch.timer_update(self)
                     return ""
     except poplib.error_protoerror, e:
         self.set_error(str(e))
Beispiel #34
0
 def check(self):
     """ Check for new mails on your pop3 account. """
     try:
         if self.ssl == True:
             if self.port != -1:
                 try:
                     s = poplib.POP3_SSL(self.host, self.port)
                 except:
                     self.set_error()
                     Watch.timer_update(self)
                     return ""
             else:
                 try:
                     s = poplib.POP3_SSL(self.host)
                 except:
                     self.set_error()
                     Watch.timer_update(self)
                     return ""
         else:
             if self.port != -1:
                 try:
                     s = poplib.POP3(self.host, self.port)
                 except:
                     self.set_error()
                     Watch.timer_update(self)
                     return ""
             else:
                 try:
                     s = poplib.POP3(self.host)
                 except:
                     self.set_error()
                     Watch.timer_update(self)
                     return ""
     except poplib.error_protoerror, e:
         self.set_error(str(e))
Beispiel #35
0
    def __init__(self, specto, id, values):
        watch_values = [("file", String(True))]

        self.icon = icon
        self.open_command = ''
        self.type_desc = type_desc
        self.standard_open_command = "xdg-open '%s'" % values['file']

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)

        self.cache_file = os.path.join(
            self.specto.CACHE_DIR,
            "file" + self.file.replace("/", "_") + ".cache")
        self.first_time = False
Beispiel #36
0
 def __init__(self, refresh, host, username, password, ssl, specto, id,  name = _("Unknown Mail Watch")):
     Watch.__init__(self, specto)
     self.name = name
     self.refresh = refresh
     self.host = host
     self.user = username
     self.password = password
     self.id = id
     self.error = False
     self.ssl = ssl
             
     cacheSubDir__ = os.environ['HOME'] + "/.specto/cache/"
     if not os.path.exists(cacheSubDir__):
         os.mkdir(cacheSubDir__)
     cacheFileName = "pop" + name + ".cache"
     self.cacheFullPath_ = os.path.join(cacheSubDir__, cacheFileName)
Beispiel #37
0
 def __init__(self,
              refresh,
              file,
              mode,
              specto,
              id,
              name=_("Unknown File Watch")):
     Watch.__init__(self, specto)
     self.name = name
     self.refresh = refresh
     self.file = file
     self.mode = mode
     self.id = id
     self.error = False
     self.first_time = False
     self.actually_updated = False
Beispiel #38
0
    def __init__(self, specto, id, values):
        watch_values = [("folder", spectlib.config.String(True))]

        self.icon = icon
        self.standard_open_command = "xdg-open '%s'" % values['folder']
        self.type_desc = type_desc

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)

        self.cache_file = os.path.join(self.specto.CACHE_DIR, "folder" + self.folder.replace("/", "_") + ".cache")
        self.first_time = False
        self.info = {}
        self.info['removed'] = [0, ""]
        self.info['created'] = [0, ""]
        self.info['modified'] = [0, ""]
Beispiel #39
0
    def check(self):
        """ See if a there are new facebook items. """
        try:
            self.updates = {'message': [], 'notification': [], 'request': [], 'wall': []}
            #message
            facebook = Facebook(self.email, self.password)
            if facebook.connect():
                self.messages = facebook.get_messages()
                for message in self.messages:
                    if message.sender + ": " + message.message not in self.previous_messages:
                        self.updates['message'].append(message.sender + ": " + message.message)
                        self.actually_changed = True
                        self.previous_messages.append(message.sender + ": " + message.message)

                # Facebook notifications
                self.notifications = facebook.get_notifications()
                for notification in self.notifications:
                    if notification.notification not in self.previous_notifications:
                        self.updates['notification'].append(notification.notification)
                        self.actually_changed = True
                        self.previous_notifications.append(notification.notification)

                # Requests
                self.requests = facebook.get_requests()
                for request in self.requests:
                    if request.request not in self.previous_requests:
                        self.updates['request'].append(request.request)
                        self.actually_changed = True
                        self.previous_requests.append(request.request)

                # Wall posts
                self.wall = facebook.get_wall()
                for w in self.wall:
                    if w.poster + ": " + w.post not in self.previous_wall:
                        self.updates['wall'].append(w.poster + ": " + w.post)
                        self.actually_changed = True
                        self.previous_wall.append(w.poster + ": " + w.post)

                self.write_cache_file()
                if len(self.messages) == 0 and len(self.notifications) == 0 and len(self.requests) == 0 and len(self.wall) == 0:
                    self.mark_as_read()
            else:
                self.set_error((_("Wrong username/password")))
        except:
            self.set_error()

        Watch.timer_update(self)
Beispiel #40
0
 def __init__(self,
              refresh,
              username,
              password,
              specto,
              id,
              name=_("Unknown Mail Watch")):
     Watch.__init__(self, specto)
     self.name = name
     self.refresh = refresh
     if "@" not in username:
         self.user = username + "@gmail.com"
     else:
         self.user = username
     self.password = password
     self.id = id
     self.error = False
Beispiel #41
0
    def __init__(self, specto, id, values):
        watch_values = [("folder", spectlib.config.String(True))]

        self.icon = icon
        self.standard_open_command = "xdg-open '%s'" % values['folder']
        self.type_desc = type_desc

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)

        self.cache_file = os.path.join(
            self.specto.CACHE_DIR,
            "folder" + self.folder.replace("/", "_") + ".cache")
        self.first_time = False
        self.info = {}
        self.info['removed'] = [0, ""]
        self.info['created'] = [0, ""]
        self.info['modified'] = [0, ""]
Beispiel #42
0
 def __init__(self,
              refresh,
              host,
              username,
              password,
              ssl,
              specto,
              id,
              name=_("Unknown Mail Watch")):
     Watch.__init__(self, specto)
     self.name = name
     self.refresh = refresh
     self.host = host
     self.user = username
     self.password = password
     self.id = id
     self.error = False
     self.ssl = ssl
Beispiel #43
0
    def check(self):
        """ See if a socket was opened or closed. """
        try:
            established = self.check_port()
            if self.running and established == False:
                self.running = False
                self.actually_changed = True
                self.status = _("Closed")
            elif self.running == False and established == True:
                self.running = True
                self.actually_changed = True
                self.status = _("Open")
            else:
                self.actually_changed = False
                self.status = _("Unknown")
        except:
            self.set_error()

        Watch.timer_update(self)
Beispiel #44
0
    def __init__(self, specto, id, values):
        watch_values = [("uri", spectlib.config.String(True)),
                        ("username", spectlib.config.String(False)),
                        ("password", spectlib.config.String(False)),
                        ("error_margin", spectlib.config.Dec(True)),
                        ("redirect", spectlib.config.Boolean(False))]

        self.standard_open_command = spectlib.util.return_webpage(values['uri'])

        Watch.__init__(self, specto, id, values, watch_values)

        self.cacheSubDir__ = specto.CACHE_DIR
        self.use_network = True
        self.filesize_difference = 0.0
        self.icon = icon

        self.open_command = self.open_command.replace("&", "\&")
        self.url_ = self.uri
        self.diff = ""
Beispiel #45
0
    def check(self):
        """ See if a socket was opened or closed. """
        try:
            established = self.check_port()
            if self.running and established == False:
                self.running = False
                self.actually_changed = True
                self.status = _("Closed")
            elif self.running == False and established == True:
                self.running = True
                self.actually_changed = True
                self.status = _("Open")
            else:
                self.actually_changed = False
                self.status = _("Unknown")
        except:
            self.set_error()

        Watch.timer_update(self)
Beispiel #46
0
    def __init__(self, specto, id, values):

        watch_values = [("folder", spectlib.config.String(True))]

        self.icon = icon
        self.standard_open_command = "xdg-open '%s'" % values['folder']
        self.type_desc = type_desc

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)

        self.use_network = True

        self.local_branch_ = 0
        self.remote_branch_ = 0
        self.remote_branch_label = ""
        self.local_extra = []
        self.remote_extra = []
        self.cache_file = os.path.join(self.specto.CACHE_DIR, "bazaar" + self.folder.replace("/", "_") + ".cache")
Beispiel #47
0
    def __init__(self, specto, id, values):

        watch_values = []
        self.icon = icon
        self.standard_open_command = 'evolution'
        self.type_desc = type_desc

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)
        
        self.dbus = True
        self.message = ""
        self.extra_info = ""
        # Use the dbus interface we saw in dbus-notify
        self.dbus_interface = "org.gnome.evolution.mail.dbus.Signal"
        self.dbus_path = "/org/gnome/evolution/mail/newmail"
        self.dbus_name = "org.gnome.evolution.mail.dbus.Signal"

        self.signals = {"NewMail": self.new_mail}
Beispiel #48
0
    def __init__(self, specto, id, values):
        watch_values = [("username", spectlib.config.String(True)),
                        ("password", spectlib.config.String(True))]
        url = "https://wave.google.com"
        self.standard_open_command = spectlib.util.return_webpage(url)

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)

        self.use_network = True
        self.icon = icon
        self.type_desc = type_desc
        self.cache_file = os.path.join(self.specto.CACHE_DIR, "gwave" + self.username + ".cache")

        #watch specific values
        self.newMsg = 0
        self.waves = Wave_collection()

        self.read_cache_file()
Beispiel #49
0
    def __init__(self, specto, id, values):

        watch_values = []
        self.icon = icon
        self.standard_open_command = 'evolution'
        self.type_desc = type_desc

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)
        
        self.dbus = True
        self.message = ""
        self.extra_info = ""
        # Use the dbus interface we saw in dbus-notify
        self.dbus_interface = "org.gnome.evolution.mail.dbus.Signal"
        self.dbus_path = "/org/gnome/evolution/mail/newmail"
        self.dbus_name = "org.gnome.evolution.mail.dbus.Signal"

        self.signals = {"NewMail": self.new_mail}
Beispiel #50
0
    def check(self):
        """ See if a process was started or stopped. """
        try:
            running_now = self.check_process()
            if self.running_initially and running_now == False:
                self.running_initially = False
                self.changed = True
                self.actually_changed = True
                self.status = _("Not running")
            elif self.running_initially == False and running_now == True:
                self.running_initially = True
                self.actually_changed = True
                self.status = _("Running")
            else:
                self.actually_changed = False
                self.status = _("Unknown")
        except:
            self.set_error()

        Watch.timer_update(self)
Beispiel #51
0
    def __init__(self, specto, id, values):

        watch_values = []
        self.icon = icon
        self.current_song = ""
        self.standard_open_command = 'rhythmbox'
        self.type_desc = type_desc

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)
        
        self.dbus = True
        self.message = ""
        self.extra_info = ""
        # Use the dbus interface we saw in dbus-notify
        self.dbus_interface = "org.gnome.Rhythmbox.Player"
        self.dbus_path = "/org/gnome/Rhythmbox/Player"
        self.dbus_name = "org.gnome.Rhythmbox"

        self.signals = {"playingUriChanged": self.playingUriChanged}
Beispiel #52
0
    def check(self):
        """ See if a process was started or stopped. """
        try:
            running_now = self.check_process()
            if self.running_initially and running_now == False:
                self.running_initially = False
                self.changed = True
                self.actually_changed = True
                self.status = _("Not running")
            elif self.running_initially == False and running_now == True:
                self.running_initially = True
                self.actually_changed = True
                self.status = _("Running")
            else:
                self.actually_changed = False
                self.status = _("Unknown")
        except:
            self.set_error()

        Watch.timer_update(self)
Beispiel #53
0
    def __init__(self, specto, id, values):

        watch_values = []
        self.icon = icon
        self.current_song = ""
        self.standard_open_command = 'banshee'
        self.type_desc = type_desc

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)

        self.dbus = True
        self.message = ""
        self.extra_info = ""
        # Use the dbus interface we saw in dbus-notify
        self.dbus_interface = "org.bansheeproject.Banshee.PlayerEngine"
        self.dbus_path = "/org/bansheeproject/Banshee/PlayerEngine"
        self.dbus_name = "org.bansheeproject.Banshee"

        self.signals = {"StateChanged": self.StateChanged}
Beispiel #54
0
    def __init__(self, specto, id, values):
        watch_values = [("username", spectlib.config.String(True)),
                        ("password", spectlib.config.String(True))]
        url = "https://wave.google.com"
        self.standard_open_command = spectlib.util.return_webpage(url)

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)

        self.use_network = True
        self.icon = icon
        self.type_desc = type_desc
        self.cache_file = os.path.join(self.specto.CACHE_DIR,
                                       "gwave" + self.username + ".cache")

        #watch specific values
        self.newMsg = 0
        self.waves = Wave_collection()

        self.read_cache_file()
Beispiel #55
0
    def __init__(self, specto, id, values):

        watch_values = []
        self.icon = icon
        self.current_song = ""
        self.standard_open_command = 'banshee'
        self.type_desc = type_desc

        #Init the superclass and set some specto values
        Watch.__init__(self, specto, id, values, watch_values)
        
        self.dbus = True
        self.message = ""
        self.extra_info = ""
        # Use the dbus interface we saw in dbus-notify
        self.dbus_interface = "org.bansheeproject.Banshee.PlayerEngine"
        self.dbus_path = "/org/bansheeproject/Banshee/PlayerEngine"
        self.dbus_name = "org.bansheeproject.Banshee"

        self.signals = {"StateChanged": self.StateChanged}
Beispiel #56
0
    def __init__(self, specto, id, values):
        watch_values = [("uri", spectlib.config.String(True)),
                        ("username", spectlib.config.String(False)),
                        ("password", spectlib.config.String(False)),
                        ("error_margin", spectlib.config.Dec(True)),
                        ("redirect", spectlib.config.Boolean(False))]

        self.standard_open_command = spectlib.util.return_webpage(
            values['uri'])

        Watch.__init__(self, specto, id, values, watch_values)

        self.cacheSubDir__ = specto.CACHE_DIR
        self.use_network = True
        self.filesize_difference = 0.0
        self.icon = icon

        self.open_command = self.open_command.replace("&", "\&")
        self.url_ = self.uri
        self.diff = ""