本文整理汇总了Python中msg.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_info
def get_info(workspace_url, project_dir):
repo_type = detect_type(project_dir)
if not repo_type:
return
msg.debug('Detected ', repo_type, ' repo in ', project_dir)
data = {
'type': repo_type,
}
cmd = REPO_MAPPING[repo_type]['cmd']
try:
p = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=project_dir)
result = p.communicate()
repo_url = result[0].decode('utf-8').strip()
if repo_type == 'svn':
repo_url = parse_svn_xml(repo_url)
msg.log(repo_type, ' url is ', repo_url)
if not repo_url:
msg.error('Error getting ', repo_type, ' url:', result[1])
return
except Exception as e:
msg.error('Error getting ', repo_type, ' url:', str_e(e))
return
data['url'] = repo_url
return data
示例2: redraw
def redraw(self) :
if self.sem_obj != None:
self.thread_lock.acquire()
try :
try :
self.sem_obj.P()
try :
shm_obj = self.shm_obj
size = struct.unpack_from("i", shm_obj.read(4,4*0))[0]
x = struct.unpack_from("i", shm_obj.read(4,4*1))[0]
y = struct.unpack_from("i", shm_obj.read(4,4*2))[0]
width = struct.unpack_from("i", shm_obj.read(4,4*3))[0]
height = struct.unpack_from("i", shm_obj.read(4,4*4))[0]
pixbufloader = gtk.gdk.PixbufLoader()
pixbufloader.write(shm_obj.read(size,4*5))
pixbufloader.close()
pixbuf = pixbufloader.get_pixbuf()
finally :
self.sem_obj.V()
pass
pixbuf.copy_area(0, 0, pixbuf.get_width(), pixbuf.get_height(), self.pixbuf, x, y)
self.rectangle = (x,y,width,height)
self.win.queue_draw_area(x,y, pixbuf.get_width(), pixbuf.get_height())
except TypeError:
msg.log("unexpected error:" + str(sys.exc_info()[0]))
pass
except :
msg.log("unexpected general error:" + str(sys.exc_info()))
pass
finally:
self.thread_lock.release()
pass
示例3: delete_buf
def delete_buf(self, path):
"""deletes a path"""
if not path:
return
path = utils.get_full_path(path)
if not self.is_shared(path):
msg.error("Skipping deleting %s because it is not in shared path %s." % (path, G.PROJECT_PATH))
return
if os.path.isdir(path):
for dirpath, dirnames, filenames in os.walk(path):
# Don't care about hidden stuff
dirnames[:] = [d for d in dirnames if d[0] != "."]
for f in filenames:
f_path = os.path.join(dirpath, f)
if f[0] == ".":
msg.log("Not deleting buf for hidden file %s" % f_path)
else:
self.delete_buf(f_path)
return
buf_to_delete = None
rel_path = utils.to_rel_path(path)
for buf_id, buf in self.FLOO_BUFS.items():
if rel_path == buf["path"]:
buf_to_delete = buf
break
if buf_to_delete is None:
msg.error("%s is not in this room" % path)
return
msg.log("deleting buffer ", rel_path)
event = {"name": "delete_buf", "id": buf_to_delete["id"]}
self.agent.put(event)
示例4: __init__
def __init__(self, parent, path):
self.parent = parent
self.size = 0
self.children = []
self.files = []
self.ignores = {
'/TOO_BIG/': []
}
self.path = utils.unfuck_path(path)
try:
paths = os.listdir(self.path)
except OSError as e:
if e.errno != errno.ENOTDIR:
raise
self.path = os.path.dirname(self.path)
self.add_file(os.path.basename(path))
return
except Exception as e:
msg.error('Error listing path %s: %s' % (path, unicode(e)))
return
msg.log('Initializing ignores for %s' % path)
for ignore_file in IGNORE_FILES:
try:
self.load(ignore_file)
except:
pass
for p in paths:
self.add_file(p)
示例5: save_floorc_json
def save_floorc_json(s):
floorc_json = {}
for k, v in s.items():
floorc_json[k.lower()] = v
msg.log('Writing ', floorc_json)
with open(G.FLOORC_JSON_PATH, 'w') as fd:
fd.write(json.dumps(floorc_json, indent=4, sort_keys=True))
示例6: send_error
def send_error(description=None, exception=None):
G.ERROR_COUNT += 1
if G.ERRORS_SENT >= G.MAX_ERROR_REPORTS:
msg.warn('Already sent %s errors this session. Not sending any more.' % G.ERRORS_SENT)
return
data = {
'jsondump': {
'error_count': G.ERROR_COUNT
},
'message': {},
'dir': G.COLAB_DIR,
}
if G.AGENT:
data['owner'] = G.AGENT.owner
data['username'] = G.AGENT.username
data['workspace'] = G.AGENT.workspace
if exception:
data['message'] = {
'description': str(exception),
'stack': traceback.format_exc(exception)
}
msg.log('Floobits plugin error! Sending exception report: %s' % data['message'])
if description:
data['message']['description'] = description
try:
# TODO: use G.AGENT.proto.host?
api_url = 'https://%s/api/log' % (G.DEFAULT_HOST)
r = api_request(G.DEFAULT_HOST, api_url, data)
G.ERRORS_SENT += 1
return r
except Exception as e:
print(e)
示例7: connect
def connect(self, cb=None):
self.stop(False)
self.empty_selects = 0
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if self.secure:
if ssl:
cert_path = os.path.join(G.COLAB_DIR, 'startssl-ca.pem')
with open(cert_path, 'wb') as cert_fd:
cert_fd.write(cert.CA_CERT.encode('utf-8'))
self.sock = ssl.wrap_socket(self.sock, ca_certs=cert_path, cert_reqs=ssl.CERT_REQUIRED)
else:
msg.log('No SSL module found. Connection will not be encrypted.')
if self.port == G.DEFAULT_PORT:
self.port = 3148 # plaintext port
msg.debug('Connecting to %s:%s' % (self.host, self.port))
try:
self.sock.connect((self.host, self.port))
if self.secure and ssl:
self.sock.do_handshake()
except socket.error as e:
msg.error('Error connecting:', e)
self.reconnect()
return
self.sock.setblocking(0)
msg.debug('Connected!')
self.reconnect_delay = G.INITIAL_RECONNECT_DELAY
self.send_auth()
if cb:
cb()
示例8: delete_buf
def delete_buf(path):
if not utils.is_shared(path):
msg.error('Skipping deleting %s because it is not in shared path %s.' % (path, G.PROJECT_PATH))
return
if os.path.isdir(path):
for dirpath, dirnames, filenames in os.walk(path):
# TODO: rexamine this assumption
# Don't care about hidden stuff
dirnames[:] = [d for d in dirnames if d[0] != '.']
for f in filenames:
f_path = os.path.join(dirpath, f)
if f[0] == '.':
msg.log('Not deleting buf for hidden file %s' % f_path)
else:
Listener.delete_buf(f_path)
return
buf_to_delete = None
rel_path = utils.to_rel_path(path)
for buf_id, buf in BUFS.items():
if rel_path == buf['path']:
buf_to_delete = buf
break
if buf_to_delete is None:
msg.error('%s is not in this room' % path)
return
msg.log('deleting buffer ', rel_path)
event = {
'name': 'delete_buf',
'id': buf_to_delete['id'],
}
Listener.agent.put(event)
示例9: on_auth
def on_auth(self):
self.authed = True
self.retries = G.MAX_RETRIES
msg.log("Successfully joined room %s/%s" % (self.owner, self.room))
if self._on_auth:
self._on_auth(self)
self._on_auth = None
示例10: on_highlight
def on_highlight(self, data):
# floobits.highlight(data['id'], region_key, data['username'], data['ranges'], data.get('ping', False))
# buf_id, region_key, username, ranges, ping=False):
ping = data.get("ping", False)
if self.follow_mode:
ping = True
buf = self.FLOO_BUFS[data["id"]]
view = self.get_view(data["id"])
if not view:
if not ping:
return
view = self.create_view(buf)
if not view:
return
if ping:
try:
offset = data["ranges"][0][0]
except IndexError as e:
msg.debug("could not get offset from range %s" % e)
else:
msg.log("You have been summoned by %s" % (data.get("username", "an unknown user")))
view.focus()
view.set_cursor_position(offset)
if G.SHOW_HIGHLIGHTS:
view.highlight(data["ranges"], data["user_id"])
示例11: create_buf
def create_buf(path):
# >>> (lambda x: lambda: x)(2)()
# TODO: check if functools can do this in st2
# really_create_buf = lambda x: (lambda: Listener.create_buf(x))
def really_create_buf(x):
return (lambda: Listener.create_buf(x))
if not utils.is_shared(path):
msg.error('Skipping adding %s because it is not in shared path %s.' % (path, G.PROJECT_PATH))
return
if os.path.isdir(path):
for dirpath, dirnames, filenames in os.walk(path):
# Don't care about hidden stuff
dirnames[:] = [d for d in dirnames if d[0] != '.']
for f in filenames:
f_path = os.path.join(dirpath, f)
if f[0] == '.':
msg.log('Not creating buf for hidden file %s' % f_path)
else:
sublime.set_timeout(really_create_buf(f_path), 0)
return
try:
buf_fd = open(path, 'rb')
buf = buf_fd.read().decode('utf-8')
rel_path = utils.to_rel_path(path)
msg.log('creating buffer ', rel_path)
event = {
'name': 'create_buf',
'buf': buf,
'path': rel_path,
}
Listener.agent.put(event)
except (IOError, OSError):
msg.error('Failed to open %s.' % path)
except Exception as e:
msg.error('Failed to create buffer %s: %s' % (path, str(e)))
示例12: stop
def stop(self):
for _conn in self._protos:
_conn.stop()
self._protos = []
self._handlers = []
msg.log("Disconnected.")
editor.status_message("Disconnected.")
示例13: update_view
def update_view(self, buf, view=None):
msg.debug('updating view for buf %s' % buf['id'])
view = view or self.get_view(buf['id'])
if not view:
msg.log('view for buf %s not found. not updating' % buf['id'])
return
self.MODIFIED_EVENTS.put(1)
view.set_text(buf['buf'])
示例14: on_delete_buf
def on_delete_buf(self, data):
# TODO: somehow tell the user about this. maybe delete on disk too?
del self.FLOO_BUFS[data['id']]
path = utils.get_full_path(data['path'])
if not G.DELETE_LOCAL_FILES:
msg.log('Not deleting %s because delete_local_files is disabled' % path)
return
utils.rm(path)
msg.warn('deleted %s because %s told me to.' % (path, data.get('username', 'the internet')))
示例15: stop
def stop(self):
msg.log('Disconnecting from room %s/%s' % (self.owner, self.room))
try:
self.retries = -1
self.sock.shutdown(2)
self.sock.close()
except Exception:
pass
msg.log('Disconnected.')