本文整理汇总了Python中support.warning函数的典型用法代码示例。如果您正苦于以下问题:Python warning函数的具体用法?Python warning怎么用?Python warning使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了warning函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: send_lowlevel
def send_lowlevel(self, user, data):
ip = user.get('ip')
port = user.get('port')
if ip == None or port == None:
warning('fetcher: No ip/port to open %s\n' % (user.tag()))
return
send_broadcast(ip, port, data)
开发者ID:proximate,项目名称:proximate,代码行数:7,代码来源:udpfetcher.py
示例2: register_rpchandler
def register_rpchandler(cmd, rpchandler):
""" register_rpchandler(cmd, rpchandler):
An RPC handler is registered. The RPC handler is used to
receive messages from network. Specifically, if an incoming
TCP connection begins with a line containing 'cmd' string,
rpchandler is called by rpchandler(data, eof, socket,
address), where 'data' is the data received so far in the
socket, 'eof' indicates whether there is more data still
coming (if 'eof' == False, data can be partial). 'socket' is
the TCP socket for remote, and 'address' is the network
address of the remote end (ip address string, remote port).
rpchandler() can be called many times until eof is True or more data
comes. This allows incremental processing of incoming message
(e.g. terminate invalid messages early).
rpchandler() returns a value that is one of:
RPC_MORE_DATA: the handler will want more data
RPC_CLOSE: the handler asks main handler to terminate the connection
RPC_RELEASE: the handler will take care of the socket from now on
"""
if rpc_commands.has_key(cmd):
warning('Can not install RPC handler: %s already exists\n' % cmd)
return False
rpc_commands[cmd] = rpchandler
return True
开发者ID:proximate,项目名称:proximate,代码行数:29,代码来源:plugins.py
示例3: get_expiring_file
def get_expiring_file(self, dt=None, rel=None):
""" Create a temp file, which expires at a given time. The temp file
is stored under user's proximate directory. The file will expire
(be deleted) after the given time. The actual deletion time is
not very accurate.
dt is a point in time, which is an instance of datetime.datetime.
If dt == None, it is assumed to be now. If rel == None,
it is assumed to be zero. Otherwise it is assumed to be a
relative delay with respect to dt.
rel is an instance of datetime.timedelta.
Hint: Use scheduler.DAY and scheduler.SECOND to specify relative
times """
assert(dt == None or isinstance(dt, datetime))
assert(rel == None or isinstance(rel, timedelta))
if dt == None:
dt = datetime.now()
if rel != None:
dt = dt + rel
# ISO date: YYYY-MM-DD-s, where s is a number of seconds in the day
isodate = str(dt.date())
seconds = str(dt.hour * 3600 + dt.minute * 60 + dt.second)
prefix = '%s-%s-%s-' % (self.EXPIRE_PREFIX, isodate, seconds)
directory = self.community.get_user_dir()
try:
(fd, fname) = mkstemp(prefix=prefix, dir=directory)
except OSError:
warning('expiring_file: mkstemp() failed\n')
return None
xclose(fd)
return fname
开发者ID:proximate,项目名称:proximate,代码行数:34,代码来源:scheduler.py
示例4: connect
def connect(self):
ip = self.user.get('ip')
port = self.user.get('port')
if not community.get_network_state(community.IP_NETWORK):
# Act as if we were missing the IP network
warning('fetcher: IP network disabled\n')
ip = None
if ip == None or port == None:
warning('fetcher: No ip/port to open %s\n' % (self.user.tag()))
return False
debug('fetcher: open from %s: %s:%s\n' % (self.user.tag(), ip, port))
if self.openingconnection == False or self.q.connect((ip, port), TP_CONNECT_TIMEOUT) == False:
return False
# The first write is seen by opposite side's RPC hander, not TCP_Queue
prefix = '%s\n' %(TP_FETCH_RECORDS)
self.q.write(prefix, writelength=False)
self.q.write(fetcher.encode(firstmsg, -1, ''))
# Close queue that is idle for a period of time. This is also the
# maximum processing time for pending requests. Requests taking
# longer than this must use other state tracking mechanisms.
self.q.set_timeout(TP_FETCH_TIMEOUT)
return True
开发者ID:proximate,项目名称:proximate,代码行数:29,代码来源:tcpfetcher.py
示例5: add_or_update_user
def add_or_update_user(self, uid, updatelist, profileversion, ip, port, profile=None):
user = get_user(uid)
newuser = (user == None)
if newuser:
user = create_user(uid)
if not user:
warning('community: Unable to create a new user %s\n' % uid)
return
if ip != None:
user.set('ip', ip)
user.set('port', port)
if newuser or user.get('v') != profileversion:
user.update_attributes(updatelist, user.get('v'))
if profile != None:
self.got_user_profile(user, profile, None)
elif not user.inprogress:
debug('Fetching new profile from user %s\n' % user.tag())
request = {'t': 'uprofile'}
if self.fetcher.fetch(user, PLUGIN_TYPE_COMMUNITY, request, self.got_user_profile):
user.inprogress = True
elif not user.present and not user.inprogress:
# User appears and user profile is already up-to-date
self.request_user_icon(user)
self.fetch_community_profiles(user)
if user.update_presence(True):
self.announce_user(user)
开发者ID:proximate,项目名称:proximate,代码行数:31,代码来源:community.py
示例6: gen_key_pair_priv_cb
def gen_key_pair_priv_cb(data, ctx):
if not data:
warning('keymanagement: Could not generate a key pair\n')
cb(None, None)
else:
xrun([self.sslname, 'rsa', '-pubout'], gen_key_pair_pub_cb,
data, data)
开发者ID:proximate,项目名称:proximate,代码行数:7,代码来源:keymanagement.py
示例7: got_community_profiles
def got_community_profiles(self, user, reply, ctx):
if reply == None:
return
validator = {
'cname': [ZERO_OR_MORE, str],
'profile': [ZERO_OR_MORE, {}]
}
if not validate(validator, reply):
warning('Invalid community profiles reply\n' % str(reply))
return
communities = self.get_user_communities(user)
for (cname, profile) in zip(reply['cname'], reply['profile']):
if cname == DEFAULT_COMMUNITY_NAME:
continue
com = self.get_ordinary_community(cname)
if com in communities:
self.update_community_profile(com, user, profile)
communities.remove(com)
# Do icon requests for the rest of communities
for com in communities:
if com.get('name') != DEFAULT_COMMUNITY_NAME:
self.request_com_icon(user, com)
开发者ID:proximate,项目名称:proximate,代码行数:26,代码来源:community.py
示例8: add_msg
def add_msg(self, msg, set_head=False):
parentid = msg.get_parentid()
msgid = msg.get_msgid()
if msgid in self.msgdict:
warning('add_msg(): Attempted to add same message twice\n')
return
# add to msgdict
self.msgdict[msgid] = msg
# update children-list of parent
if parentid != '':
# Create a new list of children if it does not exist
parent_children = self.childdict.setdefault(parentid, [])
parent_children.append(msgid)
has_parent = self.msgdict.has_key(parentid)
children = self.childdict.get(msgid, [])
# if parent of this node is not in msgdict, this is new root node
if not has_parent:
self.roots.append(msgid)
# join trees by removing roots of child trees
for childid in children:
self.roots.remove(childid)
if set_head:
self.headid = msgid
开发者ID:proximate,项目名称:proximate,代码行数:30,代码来源:messaging.py
示例9: __init__
def __init__(self):
DBusGMainLoop(set_as_default=True)
self.bus = SystemBus()
self.sessionbus = SessionBus()
try:
self.mce = self.bus.get_object("com.nokia.mce", "/com/nokia/mce")
except DBusException:
warning("Nokia MCE not found. Vibra is disabled\n")
return
self.profiled = self.sessionbus.get_object("com.nokia.profiled", "/com/nokia/profiled")
self.sessionbus.add_signal_receiver(
self.profile_changed_handler,
"profile_changed",
"com.nokia.profiled",
"com.nokia.profiled",
"/com/nokia/profiled",
)
profile = self.profiled.get_profile(dbus_interface="com.nokia.profiled")
self.get_vibra_enabled(profile)
self.register_plugin(PLUGIN_TYPE_VIBRA)
开发者ID:proximate,项目名称:proximate,代码行数:25,代码来源:vibra.py
示例10: handle_rpc_message
def handle_rpc_message(self, data, eof):
if len(data) == 0:
self.close()
return False
cmd = data[0:TP_MAX_CMD_NAME_LEN].split('\n')[0]
rpchandler = rpc_commands.get(cmd)
if rpchandler == None:
self.close()
return False
payload = data[(len(cmd) + 1):]
status = rpchandler(cmd, payload, eof, self.sock, self.address)
ret = False
if status == RPC_MORE_DATA:
ret = True
elif status == RPC_CLOSE:
self.close()
elif status == RPC_RELEASE:
# We are not interested to gobject events anymore
self.remove_io_notifications()
else:
self.close()
warning('Unknown RPC value: %s\n' %(str(status)))
return ret
开发者ID:proximate,项目名称:proximate,代码行数:27,代码来源:listener.py
示例11: read_communities
def read_communities():
global communities
if proximatedir == None:
warning('No Proximate directory\n')
return
# Read community meta datas
for dentry in os.listdir(proximatedir):
if not dentry.startswith('c_'):
continue
if str_to_int(dentry[2:], None) == None:
continue
cdir = '%s/%s' %(proximatedir, dentry)
if not os.path.isdir(cdir):
continue
cfile = '%s/profile' %(cdir)
community = Community()
try:
f = open(cfile, 'r')
except IOError:
continue
profile = f.read()
f.close()
if community.read_profile(profile):
communities[community.get('cid')] = community
defcom = get_ordinary_community(DEFAULT_COMMUNITY_NAME)
if defcom == None:
create_community(DEFAULT_COMMUNITY_NAME)
开发者ID:proximate,项目名称:proximate,代码行数:30,代码来源:proximatestate.py
示例12: init
def init():
""" Bind a default and a random port.
The random port is used for local network communication.
The default port is used to establish remote connections. """
global community
community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY)
create_tcp_listener(DEFAULT_PROXIMATE_PORT, tcp_listener_accept, reuse=True)
success = False
for i in xrange(PORT_RETRIES):
port = community.get_rpc_port()
if port == DEFAULT_PROXIMATE_PORT:
continue
(rfd, tag) = create_tcp_listener(port, tcp_listener_accept, reuse=True)
if rfd != None:
info('Listening to TCP connections on port %d\n' %(port))
success = True
break
warning('Can not bind to TCP port %d\n' %(port))
# Generate a new port number so that next iteration will not fail
if not community.gen_port():
break
if not success:
warning('Can not listen to TCP connections\n')
开发者ID:proximate,项目名称:proximate,代码行数:27,代码来源:listener.py
示例13: save_community_icon
def save_community_icon(com, icon):
# personal communities can have arbitary large icons because the picture
# is not sent over network
if com.get('peer') and len(icon) > TP_MAX_FACE_SIZE:
warning('Community %s has too large icon picture: %d\n' %(com.get('name'), len(icon)))
return False
return save_image(get_community_icon_name(com, legacyname=False), icon)
开发者ID:proximate,项目名称:proximate,代码行数:7,代码来源:proximatestate.py
示例14: chat_cb
def chat_cb(self, widget):
uid = self.msg.get('src')
user = community.get_user(uid)
if user == community.get_myself():
warning('Trying to chat with yourself')
return None
chat.messaging_gui.start_messaging(user, False)
开发者ID:proximate,项目名称:proximate,代码行数:7,代码来源:messageboard_gui.py
示例15: xmkdir
def xmkdir(dirname, mode = 0700):
try:
mkdir(dirname, mode)
except OSError, (errno, strerror):
if errno != EEXIST:
warning('Can not create a directory: %s\n' %(dirname))
return False
开发者ID:proximate,项目名称:proximate,代码行数:7,代码来源:ossupport.py
示例16: run_iteration
def run_iteration(configs_dir, execution_home, cfg, log, K, prev_K, last_one):
data_dir = os.path.join(cfg.output_dir, "K%d" % K)
stage = BASE_STAGE
saves_dir = os.path.join(data_dir, 'saves')
dst_configs = os.path.join(data_dir, "configs")
cfg_file_name = os.path.join(dst_configs, "config.info")
if options_storage.continue_mode:
if os.path.isfile(os.path.join(data_dir, "final_contigs.fasta")) and not (options_storage.restart_from and
(options_storage.restart_from == ("k%d" % K) or options_storage.restart_from.startswith("k%d:" % K))):
log.info("\n== Skipping assembler: " + ("K%d" % K) + " (already processed)")
return
if options_storage.restart_from and options_storage.restart_from.find(":") != -1:
stage = options_storage.restart_from[options_storage.restart_from.find(":") + 1:]
support.continue_from_here(log)
if stage != BASE_STAGE:
if not os.path.isdir(saves_dir):
support.error("Cannot restart from stage %s: saves were not found (%s)!" % (stage, saves_dir))
else:
if os.path.exists(data_dir):
shutil.rmtree(data_dir)
os.makedirs(data_dir)
shutil.copytree(os.path.join(configs_dir, "debruijn"), dst_configs)
# removing template configs
for root, dirs, files in os.walk(dst_configs):
for cfg_file in files:
cfg_file = os.path.join(root, cfg_file)
if cfg_file.endswith('.info.template'):
if os.path.isfile(cfg_file.split('.template')[0]):
os.remove(cfg_file)
else:
os.rename(cfg_file, cfg_file.split('.template')[0])
log.info("\n== Running assembler: " + ("K%d" % K) + "\n")
if prev_K:
additional_contigs_fname = os.path.join(cfg.output_dir, "K%d" % prev_K, "simplified_contigs.fasta")
if not os.path.isfile(additional_contigs_fname):
support.warning("additional contigs for K=%d were not found (%s)!" % (K, additional_contigs_fname), log)
additional_contigs_fname = None
else:
additional_contigs_fname = None
if "read_buffer_size" in cfg.__dict__:
construction_cfg_file_name = os.path.join(dst_configs, "construction.info")
process_cfg.substitute_params(construction_cfg_file_name, {"read_buffer_size": cfg.read_buffer_size}, log)
prepare_config_spades(cfg_file_name, cfg, log, additional_contigs_fname, K, stage, saves_dir, last_one)
command = [os.path.join(execution_home, "spades"), cfg_file_name]
## this code makes sense for src/debruijn/simplification.cpp: corrected_and_save_reads() function which is not used now
# bin_reads_dir = os.path.join(cfg.output_dir, ".bin_reads")
# if os.path.isdir(bin_reads_dir):
# if glob.glob(os.path.join(bin_reads_dir, "*_cor*")):
# for cor_filename in glob.glob(os.path.join(bin_reads_dir, "*_cor*")):
# cor_index = cor_filename.rfind("_cor")
# new_bin_filename = cor_filename[:cor_index] + cor_filename[cor_index + 4:]
# shutil.move(cor_filename, new_bin_filename)
support.sys_call(command, log)
开发者ID:starostinak,项目名称:ig_quast,代码行数:59,代码来源:spades_logic.py
示例17: xrun
def xrun(cmd, cb, ctx, inputdata=None):
""" Run 'cmd' (a list of command line arguments). Call cb(data, ctx),
when the command finishes with its output given to cb() at parameter
'data'. If 'inputdata' is given, feed it to the command from stdin.
The result is relayed through the gobject mainloop.
"""
(rfd, wfd) = xpipe()
if rfd < 0:
return False
pid = xfork()
if pid == -1:
warning('Could not fork a new process\n')
return False
if pid != 0:
xclose(wfd)
return xrunwatch(rfd, cb, ctx, pid)
xclose(rfd)
w = fdopen(wfd, 'w')
try:
pipe = Popen(cmd, stdout=PIPE, stdin=PIPE)
except OSError:
warning('Unable to run %s\n' %(' '.join(cmd)))
w.write('-1\0')
abort()
w.write(str(pipe.pid) + '\0')
w.flush()
if inputdata:
try:
pipein = pipe.stdin
pipein.write(inputdata)
except IOError:
warning("IOError while writing to command %s\n" %(' '.join(cmd)))
abort()
pipein.close()
try:
pipeout = pipe.stdout
result = pipeout.read()
except IOError:
warning("IOError while reading from command %s\n" %(' '.join(cmd)))
abort()
pipeout.close()
pipe.wait()
if pipe.returncode != 0:
warning('%s did not exit cleanly\n' %(' '.join(cmd)))
abort()
w.write(result)
w.close()
abort()
开发者ID:proximate,项目名称:proximate,代码行数:59,代码来源:ossupport.py
示例18: udp_listener_read
def udp_listener_read(self, rfd, condition):
try:
data, address = rfd.recvfrom(2048)
except socket.error, (errno, strerror):
ret = (errno == EAGAIN or errno == EINTR)
if not ret:
warning('Socket error (%s): %s\n' % (errno, strerror))
return ret
开发者ID:proximate,项目名称:proximate,代码行数:8,代码来源:udpfetcher.py
示例19: handle_message
def handle_message(self, user, sm):
""" Handle messages that were found from other users' fileshares """
if not self.validate_message(sm):
sm["ttl"] = 0
warning("msgboard: Invalid message: %s\n" % str(sm))
return
warning("New message: %s\n" % sm["subject"])
开发者ID:proximate,项目名称:proximate,代码行数:8,代码来源:messageboard.py
示例20: sym_enc
def sym_enc(self, plain, passphrase):
""" Encrypts message with AES using given passphrase """
ciph = xsystem([self.sslname, self.symmetric, '-e', '-pass', 'stdin'],
passphrase + '\n' + plain)
if not ciph:
warning('keymanagement: Unable to perform symmetric encryption\n')
return None
return ciph
开发者ID:proximate,项目名称:proximate,代码行数:8,代码来源:keymanagement.py
注:本文中的support.warning函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论