本文整理汇总了Python中spectlib.watch.Watch类的典型用法代码示例。如果您正苦于以下问题:Python Watch类的具体用法?Python Watch怎么用?Python Watch使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Watch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check
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)
示例2: __init__
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()
示例3: __init__
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()
示例4: update
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)
示例5: update
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)
示例6: update
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)
示例7: __init__
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
示例8: __init__
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,
}
示例9: __init__
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()
示例10: __init__
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
示例11: __init__
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
示例12: __init__
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
示例13: __init__
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
示例14: check
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)
示例15: __init__
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()