本文整理汇总了Python中pync.Notifier.notify方法的典型用法代码示例。如果您正苦于以下问题:Python Notifier.notify方法的具体用法?Python Notifier.notify怎么用?Python Notifier.notify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pync.Notifier
的用法示例。
在下文中一共展示了Notifier.notify方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search
# 需要导入模块: from pync import Notifier [as 别名]
# 或者: from pync.Notifier import notify [as 别名]
def search(num_colors, graph):
# Do a depth-first search over the configuration space, keeping a
# stack of assignments and variable domains.
init_cfg = Assignment(num_colors, graph)
stack = [(init_cfg, init_cfg.choose())]
while stack and not stack[-1][0].complete():
cur_var, cur_vals = stack[-1][1]
if not cur_vals:
stack.pop()
else:
# If we still have options with our current stack frame
new_val = cur_vals.pop(0)
new_cfg = stack[-1][0].set(cur_var, new_val)
if new_cfg.propagate():
stack.append((new_cfg, new_cfg.choose()))
if stack and stack[-1][0].complete():
Notifier.notify("Found a solution!",title="GraphColorizer")
return [v[0] for v in stack[-1][0].table]
else:
print "Failed @num_colors=%d" % num_colors
Notifier.notify("Failed @num_colors=%d. :(" % num_colors, title="GraphColorizer")
return search(num_colors+1, graph)
示例2: main
# 需要导入模块: from pync import Notifier [as 别名]
# 或者: from pync.Notifier import notify [as 别名]
def main():
parser = optparse.OptionParser()
using_help = '''
the service that you want to use. For example: gist for Github's Gist,
pastebin for PasteBin.com
'''
parser.add_option('-u', '--using', dest='using',
help=using_help)
(options, args) = parser.parse_args()
using = options.using
if not using:
using = 'pastebin'
obj = SharePastesFactory.create(using)
try:
url = obj.api_call(xerox.paste())
xerox.copy(url)
except xerox.base.XclipNotFound:
print 'xclip not found. Install xclip for SharePastes to work.'
sys.exit(1)
try:
from pync import Notifier
Notifier.notify('URL added to your clipboard %s.' % url,
title='SharePastes')
except:
pass
示例3: notification
# 需要导入模块: from pync import Notifier [as 别名]
# 或者: from pync.Notifier import notify [as 别名]
def notification(num,soup):
tag = soup(id=num)[0]
price = tag.parent.parent(class_="gr")[0].text
rate = tag.parent.parent(class_="bg")[0].text
brand = tag.parent.parent.a.text.encode('utf-8')
value = '%s\t%s' % (price, rate)
Notifier.notify(value.encode('utf-8'),title=brand,group=num, remove=num, sound='Glass')
示例4: notify
# 需要导入模块: from pync import Notifier [as 别名]
# 或者: from pync.Notifier import notify [as 别名]
def notify(data, buffer, date, tags, displayed, highlight, prefix, message):
if weechat.config_get_plugin('show_highlights') == 'on' and highlight == '1':
channel = weechat.buffer_get_string(buffer, 'localvar_channel')
Notifier.notify(message, title='%s %s' % (prefix, channel))
elif weechat.config_get_plugin('show_private_message') == 'on' and 'notify_private' in tags:
Notifier.notify(message, title='%s [private]' % prefix)
return weechat.WEECHAT_RC_OK
示例5: finalize
# 需要导入模块: from pync import Notifier [as 别名]
# 或者: from pync.Notifier import notify [as 别名]
def finalize(self, result):
failures = len(result.failures)
errors = len(result.errors)
folder = result.config.workingDir.strip('/').split('/')[-1]
if result.wasSuccessful():
title = "Tests passed in: %s" % folder
msg = '%s All of your %s test(s) passed!' % (
self.success_msg,
result.testsRun,
)
else:
msg = '%s %s failures, %s errors from %s tests' % (
self.failure_msg,
failures,
errors,
result.testsRun,
)
title = "Tests failed in: %s" % folder
Notifier.notify(
msg,
title=title,
group='%s_%s_tests' % (folder, self.name),
)
示例6: notify
# 需要导入模块: from pync import Notifier [as 别名]
# 或者: from pync.Notifier import notify [as 别名]
def notify(showfeed):
try:
for feed in showfeed:
content = feed['content']
retext = re.sub(ur'<.*?>', '', content, 0)
keyword = re.compile(ur'常客说|李凯|young|水洋|协议|转让', re.M)
if re.search(keyword, retext) == None:
notice = ''
else:
notice = ' ' + '⚠️' + '注意'
if feed['userinfo']['ext_info']['special_description'] == '':
description = ''
else:
description = ' ' + '🏁' + \
feed['userinfo']['ext_info']['special_description']
title = feed['userinfo']['nickname'] + notice + description
try:
contentImage = feed['images'][0]
except:
contentImage = ''
appicon = feed['userinfo']['ext_info']['avatar']
feedurl = 'https://cms.changker.com/index.php?r=weibo/view&id=' + str(feed['id'])
Notifier.notify(retext, title=title, sound='default',
appIcon=appicon, open=feedurl, contentImage=contentImage)
time.sleep(6)
except:
Notifier.notify(
'请重新启动新内容推送', title='注意!线上数据获取不成功!', sound='default', appIcon=appicon)
示例7: get_live_score
# 需要导入模块: from pync import Notifier [as 别名]
# 或者: from pync.Notifier import notify [as 别名]
def get_live_score(self):
""" show live notification score """
while True:
if self.score():
score = self.score()
Notifier.notify(score, title=self.match_title)
time.sleep(self.delay)
示例8: makeTweet
# 需要导入模块: from pync import Notifier [as 别名]
# 或者: from pync.Notifier import notify [as 别名]
def makeTweet(author, url):
code = requests.get(url)
text = code.text
soup = BeautifulSoup(text)
title = soup.findAll(attrs={'name' : 'twitter:title'})[1].get('content')
twitterHandle = ''
twitterUser = ''
twitterUrl = ''
if soup.findAll(attrs={'name' : 'twitter:creator'}):
twitterHandle = soup.findAll(attrs={'name' : 'twitter:creator'})[0].get('content')
twitterUser = twitterHandle
if 'http://twitter.com/' in twitterHandle:
twitterUser = twitterHandle.replace("http://twitter.com/", "")
elif 'https://twitter.com/' in twitterHandle:
twitterUser = twitterHandle.replace("https://twitter.com/", "")
elif 'http://www.twitter.com/' in twitterHandle:
twitterUser = twitterHandle.replace("http://www.twitter.com/", "")
elif 'https://www.twitter.com/' in twitterHandle:
twitterUser = twitterHandle.replace("https://www.twitter.com/", "")
twitterUser = twitterUser.replace("@", "")
twitterUrl = ' - (http://twitter.com/' + twitterUser + ')'
tweet = prepareTweet(title, author, twitterUser, url)
print(time.strftime("%m/%d/%Y %I:%M %p") + '\n' + title + ' by ' + author + twitterUrl + '\nLD Entry Page: ' + url)
Notifier.notify(title + ' by ' + author + twitterHandle, contentImage='img.jpg', appIcon='pp.png', title='@LDJAMBot', open='http://twitter.com/ldjambot')
return tweet
示例9: compare_values
# 需要导入模块: from pync import Notifier [as 别名]
# 或者: from pync.Notifier import notify [as 别名]
def compare_values(self,flag):
current=datetime.datetime.now()
count=0
for row in c.execute('SELECT * FROM battery'):
count=count+1
if count==0:
Notifier.notify("No values to compare")
return
direct_output = subprocess.check_output('pmset -g batt', shell=True)
(b,d)=direct_output.split('%')
(d,percentage)=b.split('InternalBattery-0\t')
if flag==1:
c.execute("INSERT INTO battery VALUES(?,? ,?)",(count+1,str(current),percentage))
conn.commit()
raw=c.execute("SELECT date,status FROM battery WHERE sl=?",(str(count)))
for i in raw:
print ''
that_time=str(i[0])
that_time=datetime.datetime.strptime(that_time, "%Y-%m-%d %H:%M:%S.%f")
that_percentage=i[1]
direct_output = subprocess.check_output('pmset -g batt', shell=True)
(b,d)=direct_output.split('%')
(d,percentage)=b.split('InternalBattery-0\t')
difference_in_percentage=int(percentage)-int(that_percentage)
difference_in_time=current-that_time
difference_in_time=str(difference_in_time)
Notifier.notify("Difference in battery percentage = {}\nDifference in time = {}".format(difference_in_percentage, difference_in_time))
示例10: notify
# 需要导入模块: from pync import Notifier [as 别名]
# 或者: from pync.Notifier import notify [as 别名]
def notify(message):
Notifier.notify(
title="Irssi Notification",
message=message,
group=os.getpid(),
activate='com.googlecode.iterm2'
)
示例11: main
# 需要导入模块: from pync import Notifier [as 别名]
# 或者: from pync.Notifier import notify [as 别名]
def main():
def sigterm_handler(_signo, _stack_frame):
try:
Notifier.notify('Unregistering fs watch', title='LittleHelp', subtitle=project_path)
except:
pass
logging.info("Sigterm handler called")
observer.unschedule(stream)
observer.stop()
observer.join()
try:
Notifier.notify('Unregistered fs watch', title='LittleHelp', subtitle=project_path)
except:
pass
sys.exit(0)
try:
Notifier.notify('Registering watch', title='LittleHelp', subtitle=project_path)
observer = Observer()
stream = Stream(file_event_callback, project_path, file_events=True)
observer.schedule(stream)
observer.start()
signal.signal(signal.SIGTERM, sigterm_handler)
while True:
sleep(0.1)
except:
logging.exception("Unhandled exception")
示例12: term_notifier
# 需要导入模块: from pync import Notifier [as 别名]
# 或者: from pync.Notifier import notify [as 别名]
def term_notifier(new_event):
new_event = new_event
filename = os.path.split(new_event)[1]
# Notifier.notify('Hello World', title = 'New file received')
Notifier.notify('New file from', title = filename, open="open, -R, "+str(new_event))
print 'Did something'
示例13: main
# 需要导入模块: from pync import Notifier [as 别名]
# 或者: from pync.Notifier import notify [as 别名]
def main():
if (Time < StartTime or EndTime < Time):
return
opacity = 1.0 if Time == StartTime else Opacity
frame = Time.GetFrame(24) if IsRendering else -1
osc.initOSCClient(port=1234)
osc.sendOSCMsg("/update", [frame, Speed / 100, opacity, Threshold, Offset, Suffix])
if IsRendering:
if Time == StartTime:
"Start Rendering~~~~~~~~~"
print "Rendering %d" % frame
if EndTime == Time:
doc.SearchObject("====OSC===")[c4d.ID_USERDATA,8] = False
print "END!!"
Notifier.notify("END!!!")
if osc.server == 0:
print "init osc server"
osc.initOSCServer(port=4321)
osc.startOSCServer()
osc.setOSCHandler(address="/save-frame", hd=onSaved)
示例14: mac_notify
# 需要导入模块: from pync import Notifier [as 别名]
# 或者: from pync.Notifier import notify [as 别名]
def mac_notify(self, title, message, config):
config = self.prepare_config(config)
try:
from pync import Notifier
except ImportError as e:
log.debug('Error importing pync: %s', e)
raise DependencyError(plugin_name, 'pync', 'pync module required. ImportError: %s' % e)
icon_path = None
try:
import flexget.ui
icon_path = os.path.join(flexget.ui.__path__[0], 'src', 'favicon.ico')
except Exception as e:
log.debug('Error trying to get flexget icon from webui folder: %s', e)
try:
Notifier.notify(
message,
subtitle=title,
title='FlexGet Notification',
appIcon=icon_path,
timeout=config['timeout'],
open=config.get('url'),
)
except Exception as e:
raise PluginWarning('Cannot send a notification: %s' % e)
示例15: notify
# 需要导入模块: from pync import Notifier [as 别名]
# 或者: from pync.Notifier import notify [as 别名]
def notify(title, message):
if hexchat.get_prefs('away_omit_alerts') and hexchat.get_info('away'):
return
if hexchat.get_prefs('gui_focus_omitalerts') and hexchat.get_info('win_status') == 'active':
return
Notifier.notify(hexchat.strip(message), title=hexchat.strip(title), sender='org.hexchat', sound='default')