• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.nonl函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中xpra.util.nonl函数的典型用法代码示例。如果您正苦于以下问题:Python nonl函数的具体用法?Python nonl怎么用?Python nonl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了nonl函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_lpinfo_drv

def get_lpinfo_drv(make_and_model):
    command = shlex.split(LPINFO) + ["--make-and-model", make_and_model, "-m"]

    def preexec():
        os.setsid()

    log("get_lpinfo_drv(%s) command=%s", make_and_model, command)
    try:
        proc = subprocess.Popen(
            command,
            stdin=None,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            shell=False,
            close_fds=True,
            preexec_fn=preexec,
        )
    except Exception as e:
        log("get_lp_info_drv(%s) lpinfo command %s failed", make_and_model, command, exc_info=True)
        log.error("Error: lpinfo command failed to run")
        log.error(" %s", e)
        log.error(" command used: '%s'", " ".join(command))
        return None
    # use the global child reaper to make sure this doesn't end up as a zombie
    from xpra.child_reaper import getChildReaper
    from xpra.util import nonl

    cr = getChildReaper()
    cr.add_process(proc, "lpinfo", command, ignore=True, forget=True)
    from xpra.make_thread import make_thread

    def watch_lpinfo():
        # give it 15 seconds to run:
        for _ in range(15):
            if proc.poll() is not None:
                return  # finished already
            time.sleep(1)
        log.warn("Warning: lpinfo command is taking too long")
        proc.terminate()

    make_thread(watch_lpinfo, "lpinfo watcher", daemon=True).start()
    out, err = proc.communicate()
    if proc.wait() != 0:
        log.warn("Warning: lpinfo command failed and returned %s", proc.returncode)
        log.warn(" command used: '%s'", " ".join(command))
        return None
    if sys.version_info[0] >= 3:
        try:
            out = out.decode()
        except:
            out = str(out)
    log("lpinfo out=%s", nonl(out))
    log("lpinfo err=%s", nonl(err))
    if err:
        log.warn("Warning: lpinfo command produced some warnings:")
        log.warn(" '%s'", nonl(err))
    for line in out.splitlines():
        if line.startswith("drv://"):
            return line.split(" ")[0]
    return None
开发者ID:svn2github,项目名称:Xpra,代码行数:60,代码来源:pycups_printing.py


示例2: safe_exec

def safe_exec(cmd, stdin=None, log_errors=True, **kwargs):
    process = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs)
    out, err = process.communicate(stdin)
    code = process.poll()
    l=log.debug
    if code!=0 and log_errors:
        l=log.error
    l("signal_safe_exec(%s, %s, %s) stdout='%s'", cmd, stdin, kwargs, nonl(out))
    l("signal_safe_exec(%s, %s, %s) stderr='%s'", cmd, stdin, kwargs, nonl(err))
    return  code, out, err
开发者ID:ljmljz,项目名称:xpra,代码行数:10,代码来源:exec_util.py


示例3: get_keymap_spec

 def get_keymap_spec(self):
     log("get_keymap_spec() keyboard_bindings=%s", self.keyboard_bindings)
     if not self.keyboard_bindings:
         return None
     _query_struct = self.keyboard_bindings.getXkbProperties()
     _query = xkbmap_query_tostring(_query_struct)
     log("get_keymap_spec() Xkb query tostring(%s)=%s", _query_struct, _query)
     #we no longer support servers via xkbmap_print:
     xkbmap_print = ""
     log("get_keymap_spec()=(%s, %s, %s)", nonl(xkbmap_print), nonl(_query), nonl(_query_struct))
     return xkbmap_print, _query, _query_struct
开发者ID:svn2github,项目名称:Xpra,代码行数:11,代码来源:keyboard.py


示例4: query_xkbmap

 def query_xkbmap(self):
     self.xkbmap_layout, self.xkbmap_variant, self.xkbmap_variants = self.keyboard.get_layout_spec()
     self.xkbmap_print, self.xkbmap_query = self.keyboard.get_keymap_spec()
     self.xkbmap_keycodes = self.get_full_keymap()
     self.xkbmap_x11_keycodes = self.keyboard.get_x11_keymap()
     self.xkbmap_mod_meanings, self.xkbmap_mod_managed, self.xkbmap_mod_pointermissing = self.keyboard.get_keymap_modifiers()
     debug("layout=%s, variant=%s", self.xkbmap_layout, self.xkbmap_variant)
     debug("print=%s, query=%s", nonl(self.xkbmap_print), nonl(self.xkbmap_query))
     debug("keycodes=%s", str(self.xkbmap_keycodes)[:80]+"...")
     debug("x11 keycodes=%s", str(self.xkbmap_x11_keycodes)[:80]+"...")
     debug("xkbmap_mod_meanings: %s", self.xkbmap_mod_meanings)
开发者ID:Brainiarc7,项目名称:xpra,代码行数:11,代码来源:keyboard_helper.py


示例5: query_xkbmap

 def query_xkbmap(self):
     self.xkbmap_layout, self.xkbmap_layouts, self.xkbmap_variant, self.xkbmap_variants = self.get_layout_spec()
     self.xkbmap_print, self.xkbmap_query, self.xkbmap_query_struct = self.get_keymap_spec()
     self.xkbmap_keycodes = self.get_full_keymap()
     self.xkbmap_x11_keycodes = self.keyboard.get_x11_keymap()
     self.xkbmap_mod_meanings, self.xkbmap_mod_managed, self.xkbmap_mod_pointermissing = self.keyboard.get_keymap_modifiers()
     self.update_hash()
     log("layout=%s, layouts=%s, variant=%s, variants=%s", self.xkbmap_layout, self.xkbmap_layouts, self.xkbmap_variant, self.xkbmap_variants)
     log("print=%s, query=%s, struct=%s", nonl(self.xkbmap_print), nonl(self.xkbmap_query), nonl(self.xkbmap_query_struct))
     log("keycodes=%s", str(self.xkbmap_keycodes)[:80]+"...")
     log("x11 keycodes=%s", str(self.xkbmap_x11_keycodes)[:80]+"...")
     log("mod managed: %s", self.xkbmap_mod_managed)
     log("mod meanings: %s", self.xkbmap_mod_meanings)
     log("mod pointermissing: %s", self.xkbmap_mod_pointermissing)
     log("hash=%s", self.hash)
开发者ID:svn2github,项目名称:Xpra,代码行数:15,代码来源:keyboard_helper.py


示例6: get_text_data

 def get_text_data(self):
     data = []
     tb = self.description.get_buffer()
     buf = tb.get_text(*tb.get_bounds(), include_hidden_chars=False)
     if len(buf):
         data.append(("Description", "", "txt", buf))
     for name, dtype, title, value_cb, tooltip in self.toggles:
         if not bool(value_cb):
             continue
         cb = getattr(self, name)
         assert cb is not None
         if not cb.get_active():
             continue
         #OK, the checkbox is selected, get the data
         value = value_cb
         if type(value_cb)!=dict:
             try:
                 value = value_cb()
             except TypeError:
                 log.error("error on %s", value_cb, exc_info=True)
                 value = str(value_cb)
                 dtype = "txt"
             except Exception as e:
                 value = e
                 dtype = "txt"
         if value is None:
             value = "not available"
         elif type(value)==dict:
             s = os.linesep.join("%s : %s" % (k.ljust(32), nonl(str(v))) for k,v in sorted(value.items()))
         elif type(value) in (list, tuple):
             s = os.linesep.join(str(x) for x in value)
         else:
             s = str(value)
         data.append((title, tooltip, dtype, s))
     return data
开发者ID:ljmljz,项目名称:xpra,代码行数:35,代码来源:bug_report.py


示例7: _process_ack_file_chunk

 def _process_ack_file_chunk(self, packet):
     #the other end received our send-file or send-file-chunk,
     #send some more file data
     filelog("ack-file-chunk: %s", packet[1:])
     chunk_id, state, error_message, chunk = packet[1:5]
     if not state:
         filelog.error("Error: remote end is cancelling the file transfer:")
         filelog.error(" %s", error_message)
         del self.send_chunks_in_progress[chunk_id]
         return
     chunk_state = self.send_chunks_in_progress.get(chunk_id)
     if not chunk_state:
         filelog.error("Error: cannot find the file transfer id '%s'", nonl(chunk_id))
         return
     if chunk_state[-1]!=chunk:
         filelog.error("Error: chunk number mismatch (%i vs %i)", chunk_state, chunk)
         del self.send_chunks_in_progress[chunk_id]
         return
     start_time, data, chunk_size, timer, chunk = chunk_state
     if not data:
         #all sent!
         elapsed = time.time()-start_time
         filelog("%i chunks of %i bytes sent in %ims (%sB/s)", chunk, chunk_size, elapsed*1000, std_unit(chunk*chunk_size/elapsed))
         del self.send_chunks_in_progress[chunk_id]
         return
     assert chunk_size>0
     #carve out another chunk:
     cdata = self.compressed_wrapper("file-data", data[:chunk_size])
     data = data[chunk_size:]
     chunk += 1
     if timer:
         self.source_remove(timer)
     timer = self.timeout_add(CHUNK_TIMEOUT, self._check_chunk_sending, chunk_id, chunk)
     self.send_chunks_in_progress[chunk_id] = [start_time, data, chunk_size, timer, chunk]
     self.send("send-file-chunk", chunk_id, chunk, cdata, bool(data))
开发者ID:svn2github,项目名称:Xpra,代码行数:35,代码来源:file_transfer.py


示例8: get_keymap_spec

 def get_keymap_spec(self):
     v = self.get_keymap_spec_from_xkb()
     if not v:
         v = self.get_keymap_spec_using_setxkbmap()
     from xpra.util import nonl
     log("get_keymap_spec()=%s", nonl(str(v)))
     return v
开发者ID:svn2github,项目名称:Xpra,代码行数:7,代码来源:keyboard.py


示例9: _process_hello

 def _process_hello(self, packet):
     log.debug("process_hello: %s", packet)
     props = packet[1]
     if props:
         def sorted_nicely(l):
             """ Sort the given iterable in the way that humans expect."""
             def convert(text):
                 if text.isdigit():
                     return int(text)
                 else:
                     return text
             alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', bytestostr(key)) ]
             return sorted(l, key = alphanum_key)
         for k in sorted_nicely(props.keys()):
             v = props.get(k)
             if sys.version_info[0]>=3:
                 #FIXME: this is a nasty and horrible python3 workaround (yet again)
                 #we want to print bytes as strings without the ugly 'b' prefix..
                 #it assumes that all the strings are raw or in (possibly nested) lists or tuples only
                 def fixvalue(w):
                     if type(w)==bytes:
                         return bytestostr(w)
                     elif type(w) in (tuple,list):
                         return type(w)([fixvalue(x) for x in w])
                     return w
                 v = fixvalue(v)
             log.info("%s=%s", bytestostr(k), nonl(v))
     self.quit(0)
开发者ID:svn2github,项目名称:Xpra,代码行数:28,代码来源:gobject_client_base.py


示例10: main

def main():
    from xpra.platform import init as platform_init, clean
    from xpra.util import nonl
    from xpra.log import enable_color

    try:
        platform_init("GUI-Properties")
        enable_color()
        init()
        verbose = "-v" in sys.argv or "--verbose" in sys.argv
        if verbose:
            from xpra.log import get_all_loggers

            for x in get_all_loggers():
                x.enable_debug()

        # naughty, but how else can I hook this up?
        import os

        if os.name == "posix":
            try:
                from xpra.x11.bindings import posix_display_source  # @UnusedImport
            except:
                pass  # maybe running on OSX? hope for the best..
        i = get_info()
        for k in sorted(i.keys()):
            v = i[k]
            print("* %s : %s" % (k.ljust(32), nonl(v)))
    finally:
        clean()
开发者ID:svn2github,项目名称:Xpra,代码行数:30,代码来源:gui.py


示例11: print_options

 def print_options(o):
     for k,ot in sorted(OPTION_TYPES.items()):
         v = getattr(o, name_to_field(k), "")
         if ot==bool and v is None:
             v = "Auto"
         if type(v)==list:
             v = ", ".join(str(x) for x in v)
         print("* %-32s : %s" % (k, nonl(v)))
开发者ID:svn2github,项目名称:Xpra,代码行数:8,代码来源:config.py


示例12: print_options

 def print_options(o):
     for k,ot in sorted(OPTION_TYPES.items()):
         attr_name = k.replace("-", "_")
         v = getattr(o, attr_name, "")
         if ot==bool and v is None:
             v = "Auto"
         if type(v)==list:
             v = ", ".join(str(x) for x in v)
         print("* %-32s : %s" % (k, nonl(v)))
开发者ID:svn2github,项目名称:Xpra,代码行数:9,代码来源:config.py


示例13: _process_send_file_chunk

 def _process_send_file_chunk(self, packet):
     chunk_id, chunk, file_data, has_more = packet[1:5]
     filelog("_process_send_file_chunk%s", (chunk_id, chunk, "%i bytes" % len(file_data), has_more))
     chunk_state = self.receive_chunks_in_progress.get(chunk_id)
     if not chunk_state:
         filelog.error("Error: cannot find the file transfer id '%s'", nonl(chunk_id))
         self.send("ack-file-chunk", chunk_id, False, "file transfer id not found", chunk)
         return
     fd = chunk_state[1]
     if chunk_state[-1]+1!=chunk:
         filelog.error("Error: chunk number mismatch, expected %i but got %i", chunk_state[-1]+1, chunk)
         self.send("ack-file-chunk", chunk_id, False, "chunk number mismatch", chunk)
         del self.receive_chunks_in_progress[chunk_id]
         os.close(fd)
         return
     #update chunk number:
     chunk_state[-1] = chunk
     digest = chunk_state[8]
     written = chunk_state[9]
     try:
         os.write(fd, file_data)
         digest.update(file_data)
         written += len(file_data)
         chunk_state[9] = written
     except OSError as e:
         filelog.error("Error: cannot write file chunk")
         filelog.error(" %s", e)
         self.send("ack-file-chunk", chunk_id, False, "write error: %s" % e, chunk)
         del self.receive_chunks_in_progress[chunk_id]
         try:
             os.close(fd)
         except:
             pass
         return
     self.send("ack-file-chunk", chunk_id, True, "", chunk)
     if has_more:
         timer = chunk_state[-2]
         if timer:
             self.source_remove(timer)
         #remote end will send more after receiving the ack
         timer = self.timeout_add(CHUNK_TIMEOUT, self._check_chunk_receiving, chunk_id, chunk)
         chunk_state[-2] = timer
         return
     del self.receive_chunks_in_progress[chunk_id]
     os.close(fd)
     #check file size and digest then process it:
     filename, mimetype, printit, openit, filesize, options = chunk_state[2:8]
     if written!=filesize:
         filelog.error("Error: expected a file of %i bytes, got %i", filesize, written)
         return
     expected_digest = options.get("sha1")
     if expected_digest:
         self.check_digest(filename, digest.hexdigest(), expected_digest)
     start_time = chunk_state[0]
     elapsed = time.time()-start_time
     filelog("%i bytes received in %i chunks, took %ims", filesize, chunk, elapsed*1000)
     self.do_process_downloaded_file(filename, mimetype, printit, openit, filesize, options)
开发者ID:svn2github,项目名称:Xpra,代码行数:57,代码来源:file_transfer.py


示例14: _process_disconnect

 def _process_disconnect(self, packet):
     #ie: ("disconnect", "version error", "incompatible version")
     reason = bytestostr(packet[1])
     info = packet[2:]
     s = nonl(reason)
     if len(info):
         s += " (%s)" % (", ".join([nonl(bytestostr(x)) for x in info]))
     if self.server_capabilities is None or len(self.server_capabilities)==0:
         #server never sent hello to us - so disconnect is an error
         #(but we don't know which one - the info message may help)
         log.warn("server failure: disconnected before the session could be established")
         e = EXIT_FAILURE
     elif disconnect_is_an_error(reason):
         log.warn("server failure: %s", reason)
         e = EXIT_FAILURE
     else:
         e = EXIT_OK
     self.warn_and_quit(e, "server requested disconnect: %s" % s)
开发者ID:svn2github,项目名称:Xpra,代码行数:18,代码来源:client_base.py


示例15: _open_file

 def _open_file(self, filename):
     if not self.open_files:
         log.warn("Warning: opening files automatically is disabled,")
         log.warn(" ignoring uploaded file:")
         log.warn(" '%s'", filename)
         return
     import subprocess
     PIPE = subprocess.PIPE
     process = subprocess.Popen([self.open_command, filename], stdin=PIPE, stdout=PIPE, stderr=PIPE)
     out, err = process.communicate()
     r = process.wait()
     filelog.info("opened file %s with %s, exit code: %s", filename, self.open_command, r)
     if r!=0:
         l = filelog.warn
     else:
         l = filelog
     if out:
         l("stdout=%s", nonl(out)[:512])
     if err:
         l("stderr=%s", nonl(err)[:512])
开发者ID:svn2github,项目名称:Xpra,代码行数:20,代码来源:client_base.py


示例16: get_lpinfo_drv

def get_lpinfo_drv(make_and_model):
    command = shlex.split(LPINFO) + ["--make-and-model", make_and_model, "-m"]

    def preexec():
        os.setsid()

    log("get_lpinfo_drv(%s) command=%s", make_and_model, command)
    proc = subprocess.Popen(
        command,
        stdin=None,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        shell=False,
        close_fds=True,
        preexec_fn=preexec,
    )
    # use the global child reaper to make sure this doesn't end up as a zombie
    from xpra.child_reaper import getChildReaper
    from xpra.util import nonl

    cr = getChildReaper()
    cr.add_process(proc, "lpinfo", command, ignore=True, forget=True)
    out, err = proc.communicate()
    if proc.wait() != 0:
        log.warn("Warning: lpinfo command failed and returned %s", proc.returncode)
        log.warn(" command used: '%s'", command)
        return None
    if sys.version_info[0] >= 3:
        try:
            out = out.decode()
        except:
            out = str(out)
    log("lpinfo out=%s", nonl(out))
    log("lpinfo err=%s", nonl(err))
    if err:
        log.warn("Warning: lpinfo command produced some warnings:")
        log.warn(" '%s'", nonl(err))
    for line in out.splitlines():
        if line.startswith("drv://"):
            return line.split(" ")[0]
    return None
开发者ID:svn2github,项目名称:Xpra,代码行数:41,代码来源:pycups_printing.py


示例17: main

def main():
    #use gtk as display source:
    from xpra.x11.gtk_x11 import gdk_display_source
    assert gdk_display_source
    from xpra.util import nonl
    from xpra.platform import init as platform_init
    platform_init("GTK-Keyboard", "GTK Keyboard")

    x = GTKKeyboardHelper(None, True, "")
    x.query_xkbmap()
    for k,v in x.get_keymap_properties().items():
        print("%s=%s" % (k,nonl(v)))
开发者ID:svn2github,项目名称:Xpra,代码行数:12,代码来源:gtk_keyboard_helper.py


示例18: defaults_init

    def defaults_init(self):
        # skip warning when running the client
        from xpra import child_reaper

        child_reaper.POLL_WARNING = False
        getChildReaper()
        log("XpraClientBase.defaults_init() os.environ:")
        for k, v in os.environ.items():
            log(" %s=%s", k, nonl(v))
        # client state:
        self.exit_code = None
        self.exit_on_signal = False
        self.display_desc = {}
        # connection attributes:
        self.hello_extra = {}
        self.compression_level = 0
        self.display = None
        self.username = None
        self.password = None
        self.password_file = None
        self.password_sent = False
        self.encryption = None
        self.encryption_keyfile = None
        self.server_padding_options = [DEFAULT_PADDING]
        self.quality = -1
        self.min_quality = 0
        self.speed = 0
        self.min_speed = -1
        self.printer_attributes = []
        self.send_printers_timer = None
        self.exported_printers = None
        # protocol stuff:
        self._protocol = None
        self._priority_packets = []
        self._ordinary_packets = []
        self._mouse_position = None
        self._aliases = {}
        self._reverse_aliases = {}
        # server state and caps:
        self.server_capabilities = None
        self._remote_machine_id = None
        self._remote_uuid = None
        self._remote_version = None
        self._remote_revision = None
        self._remote_platform = None
        self._remote_platform_release = None
        self._remote_platform_platform = None
        self._remote_platform_linux_distribution = None
        self.uuid = get_user_uuid()
        self.init_packet_handlers()
        sanity_checks()
开发者ID:svn2github,项目名称:Xpra,代码行数:51,代码来源:client_base.py


示例19: dump_dict

 def dump_dict(d):
     pk = None
     try:
         for pk,pv in d.items():
             try:
                 if type(pv)==unicode:
                     sv = pv.encode("utf8")
                 else:
                     sv = nonl(pver(pv))
             except Exception as e:
                 sv = repr(pv)
             print("        %s : %s" % (pk.ljust(32), sv))
     except Exception as e:
         print("        error on %s: %s" % (pk, e))
         print("        raw attributes: " % d)
开发者ID:svn2github,项目名称:Xpra,代码行数:15,代码来源:printing.py


示例20: get_pactl_stat_line

def get_pactl_stat_line(prefix):
    if not has_pa():
        return ""
    code, out, err = pactl_output(False, "stat")
    if code!=0:
        log.warn("Warning: failed to query pulseaudio using 'pactl list'")
        if err:
            log.warn(" %s", nonl(err))
        return    ""
    stat = ""
    for line in out.splitlines():
        if line.startswith(prefix):
            stat = line[len(prefix):].strip()
            break
    log("get_pactl_stat_line(%s)=%s", prefix, stat)
    return stat
开发者ID:svn2github,项目名称:Xpra,代码行数:16,代码来源:pulseaudio_pactl_util.py



注:本文中的xpra.util.nonl函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.repr_ellipsized函数代码示例发布时间:2022-05-26
下一篇:
Python util.csv函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap