当前位置: 首页>>代码示例>>Python>>正文


Python Logger.info方法代码示例

本文整理汇总了Python中xpra.log.Logger.info方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.info方法的具体用法?Python Logger.info怎么用?Python Logger.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xpra.log.Logger的用法示例。


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

示例1: start_children

# 需要导入模块: from xpra.log import Logger [as 别名]
# 或者: from xpra.log.Logger import info [as 别名]
def start_children(child_reaper, cwd, commands, fake_xinerama):
    assert os.name == "posix"
    from xpra.log import Logger

    log = Logger("server")
    env = os.environ.copy()
    # add fake xinerama:
    if fake_xinerama:
        libfakeXinerama_so = find_fakeXinerama()
        if libfakeXinerama_so:
            env["LD_PRELOAD"] = libfakeXinerama_so
    # disable ubuntu's global menu using env vars:
    env.update(
        {
            "UBUNTU_MENUPROXY": "",
            "QT_X11_NO_NATIVE_MENUBAR": "1",
            "MWNOCAPTURE": "true",
            "MWNO_RIT": "true",
            "MWWM": "allwm",
        }
    )
    for child_cmd in commands:
        if not child_cmd:
            continue
        try:
            proc = subprocess.Popen(child_cmd, stdin=subprocess.PIPE, env=env, cwd=cwd, shell=True, close_fds=True)
            child_reaper.add_process(proc, child_cmd)
            log.info("started child '%s' with pid %s", child_cmd, proc.pid)
        except OSError, e:
            sys.stderr.write("Error spawning child '%s': %s\n" % (child_cmd, e))
开发者ID:svn2github,项目名称:Xpra,代码行数:32,代码来源:server.py

示例2: console_event_catcher

# 需要导入模块: from xpra.log import Logger [as 别名]
# 或者: from xpra.log.Logger import info [as 别名]
class console_event_catcher(object):
    def __init__(self, event_cb, events=CONSOLE_EXIT_EVENTS):
        self.event_cb = event_cb
        self.events = events
        self.result = 0
        from xpra.log import Logger

        self.log = Logger("win32")

    def __enter__(self):
        try:
            self.result = win32api.SetConsoleCtrlHandler(self.handle_console_event, 1)
            if self.result == 0:
                self.log.error("could not SetConsoleCtrlHandler (error %r)", win32api.GetLastError())
        except Exception as e:
            self.log.error("SetConsoleCtrlHandler error: %s", e)

    def __exit__(self, exc_type, exc_val, exc_tb):
        try:
            win32api.SetConsoleCtrlHandler(None, 0)
        except:
            pass

    def __repr__(self):
        return "console_event_catcher(%s, %s)" % (self.event_cb, self.events)

    def handle_console_event(self, event):
        self.log("handle_console_event(%s)", event)
        if event in self.events:
            self.log.info("received console event %s", event)
            self.event_cb(event)
开发者ID:svn2github,项目名称:Xpra,代码行数:33,代码来源:__init__.py

示例3: ChildReaper

# 需要导入模块: from xpra.log import Logger [as 别名]
# 或者: from xpra.log.Logger import info [as 别名]
class ChildReaper(object):
    def __init__(self, quit_cb, children_pids={}):
        self._quit = quit_cb
        self._children_pids = children_pids
        self._dead_pids = set()
        from xpra.log import Logger
        self._logger = Logger()

    def check(self):
        if self._children_pids:
            pids = set(self._children_pids.keys())
            if pids.issubset(self._dead_pids):
                self._quit()

    def sigchld(self, signum, frame):
        self.reap()

    def add_dead_pid(self, pid):
        if pid not in self._dead_pids:
            cmd = self._children_pids.get(pid)
            if cmd:
                self._logger.info("child '%s' with pid %s has terminated", cmd, pid)
            self._dead_pids.add(pid)
            self.check()

    def reap(self):
        while True:
            try:
                pid, _ = os.waitpid(-1, os.WNOHANG)
            except OSError:
                break
            if pid == 0:
                break
            self.add_dead_pid(pid)
开发者ID:svn2github,项目名称:Xpra,代码行数:36,代码来源:server.py

示例4: do_log_screen_sizes

# 需要导入模块: from xpra.log import Logger [as 别名]
# 或者: from xpra.log.Logger import info [as 别名]
def do_log_screen_sizes(root_w, root_h, ss):
    from xpra.log import Logger
    log = Logger()
    log.info("root size is %sx%s with %s screen(s):", root_w, root_h, len(ss))
    def prstr(s, default=""):
        if not s:
            return default
        #prettify strings on win32
        return s.lstrip("0\\").lstrip(".\\").replace("0\\", "-")
    #old format, used by some clients (android):
    if len(ss)==2 and type(ss[0])==int and type(ss[1])==int:
        return
    for s in ss:
        if len(s)<10:
            log.info(" %s", s)
            continue
        #more detailed output:
        display_name, width, height, width_mm, height_mm, \
        monitors, work_x, work_y, work_width, work_height = s[:11]
        log.info("  '%s' %sx%s (%sx%s mm) workarea: %sx%s at %sx%s",
                    prstr(display_name), width, height, width_mm, height_mm,
                    work_width, work_height, work_x, work_y)
        i = 0
        for m in monitors:
            i += 1
            if len(m)<7:
                log.info("    %s", m)
                continue
            plug_name, x, y, width, height, wmm, hmm = m[:8]
            log.info("    '%s' %sx%s at %sx%s (%sx%s mm)", prstr(plug_name, "monitor %s" % i), width, height, x, y, wmm, hmm)
开发者ID:svn2github,项目名称:Xpra,代码行数:32,代码来源:util.py

示例5: start_children

# 需要导入模块: from xpra.log import Logger [as 别名]
# 或者: from xpra.log.Logger import info [as 别名]
def start_children(child_reaper, commands, fake_xinerama):
    assert os.name=="posix"
    from xpra.log import Logger
    log = Logger()
    env = os.environ.copy()
    #add fake xinerama:
    if fake_xinerama:
        #locate the fakeXinerama lib:
        #it would be better to rely on dlopen to find the paths
        #but I cannot find a way of getting ctypes to tell us the path
        #it found the library in
        libpaths = os.environ.get("LD_LIBRARY_PATH", "").split(":")
        libpaths.append("/usr/lib64")
        libpaths.append("/usr/lib")
        for libpath in libpaths:
            if not libpath or not os.path.exists(libpath):
                continue
            libfakeXinerama_so = "%s/%s" % (libpath, "libfakeXinerama.so.1")
            if os.path.exists(libfakeXinerama_so):
                env["LD_PRELOAD"] = libfakeXinerama_so
    #disable ubuntu's global menu using env vars:
    env.update({
        "UBUNTU_MENUPROXY"          : "",
        "QT_X11_NO_NATIVE_MENUBAR"  : "1"})
    for child_cmd in commands:
        if not child_cmd:
            continue
        try:
            proc = subprocess.Popen(child_cmd, stdin=subprocess.PIPE, env=env, shell=True, close_fds=True)
            child_reaper.add_process(proc, child_cmd)
            log.info("started child '%s' with pid %s", child_cmd, proc.pid)
        except OSError, e:
            sys.stderr.write("Error spawning child '%s': %s\n" % (child_cmd, e))
开发者ID:Brainiarc7,项目名称:xpra,代码行数:35,代码来源:server.py

示例6: PIL_logging_workaround

# 需要导入模块: from xpra.log import Logger [as 别名]
# 或者: from xpra.log.Logger import info [as 别名]
def PIL_logging_workaround():
    import logging

    PIL_DEBUG = os.environ.get("XPRA_PIL_DEBUG", "0") == "1"
    if PIL_DEBUG:
        from xpra.log import Logger

        log = Logger("util")
        log.info("enabling PIL.DEBUG")
        level = logging.DEBUG
    else:
        level = logging.INFO

    # newer versions use this logger,
    # we must initialize it before we load the class:
    for x in ("Image", "PngImagePlugin", "WebPImagePlugin", "JpegImagePlugin"):
        logger = logging.getLogger("PIL.%s" % x)
        logger.setLevel(level)
    import PIL
    from PIL import Image

    assert PIL and Image
    if hasattr(Image, "DEBUG"):
        # for older versions (pre 3.0), use Image.DEBUG flag:
        Image.DEBUG = int(PIL_DEBUG)
开发者ID:svn2github,项目名称:Xpra,代码行数:27,代码来源:loader.py

示例7: do_log_screen_sizes

# 需要导入模块: from xpra.log import Logger [as 别名]
# 或者: from xpra.log.Logger import info [as 别名]
def do_log_screen_sizes(root_w, root_h, sizes):
    from xpra.log import Logger

    log = Logger()
    # old format, used by some clients (android):
    if type(sizes) not in (tuple, list):
        return
    if any(True for x in sizes if type(x) not in (tuple, list)):
        return

    def dpi(size_pixels, size_mm):
        if size_mm == 0:
            return 0
        return int(size_pixels * 254 / size_mm / 10)

    for s in sizes:
        if len(s) < 10:
            log.info(" %s", s)
            continue
        # more detailed output:
        display_name, width, height, width_mm, height_mm, monitors, work_x, work_y, work_width, work_height = s[:10]
        # always log plug name:
        info = ["'%s'" % prettify_plug_name(display_name)]
        if width != root_w or height != root_h:
            # log plug dimensions if not the same as display (root):
            info.append("%sx%s" % (width, height))
        info.append("(%sx%s mm - DPI: %sx%s)" % (width_mm, height_mm, dpi(width, width_mm), dpi(height, height_mm)))

        def add_workarea(wx, wy, ww, wh):
            info.append("workarea: %sx%s" % (ww, wh))
            if wx != 0 or wy != 0:
                # log position if not (0, 0)
                info.append("at %sx%s" % (wx, wy))

        if work_width != width or work_height != height or work_x != 0 or work_y != 0:
            add_workarea(work_x, work_y, work_width, work_height)
        log.info("  " + " ".join(info))
        for i, m in enumerate(monitors, start=1):
            if len(m) < 7:
                log.info("    %s", m)
                continue
            plug_name, plug_x, plug_y, plug_width, plug_height, plug_width_mm, plug_height_mm = m[:7]
            info = ["%s" % prettify_plug_name(plug_name, "monitor %s" % i)]
            if plug_width != width or plug_height != height or plug_x != 0 or plug_y != 0:
                info.append("%sx%s" % (plug_width, plug_height))
                if plug_x != 0 or plug_y != 0:
                    info.append("at %sx%s" % (plug_x, plug_y))
            if (plug_width_mm != width_mm or plug_height_mm != height_mm) and (plug_width_mm > 0 or plug_height_mm > 0):
                info.append(
                    "(%sx%s mm - DPI: %sx%s)"
                    % (plug_width_mm, plug_height_mm, dpi(plug_width, plug_width_mm), dpi(plug_height, plug_height_mm))
                )
            if len(m) >= 11:
                work_x, work_y, work_width, work_height = m[7:11]
                add_workarea(work_x, work_y, work_width, work_height)
            log.info("    " + " ".join(info))
开发者ID:svn2github,项目名称:Xpra,代码行数:58,代码来源:util.py

示例8: start_children

# 需要导入模块: from xpra.log import Logger [as 别名]
# 或者: from xpra.log.Logger import info [as 别名]
def start_children(child_reaper, commands):
    assert os.name=="posix"
    from xpra.log import Logger
    log = Logger()
    #disable ubuntu's global menu using env vars:
    env = os.environ.copy()
    env.update({
        "UBUNTU_MENUPROXY"          : "",
        "QT_X11_NO_NATIVE_MENUBAR"  : "1"})
    for child_cmd in commands:
        if not child_cmd:
            continue
        try:
            proc = subprocess.Popen(child_cmd, stdin=subprocess.PIPE, env=env, shell=True, close_fds=True)
            child_reaper.add_process(proc, child_cmd)
            log.info("started child '%s' with pid %s", child_cmd, proc.pid)
        except OSError, e:
            sys.stderr.write("Error spawning child '%s': %s\n" % (child_cmd, e))
开发者ID:svn2github,项目名称:Xpra,代码行数:20,代码来源:server.py

示例9: start_pulseaudio

# 需要导入模块: from xpra.log import Logger [as 别名]
# 或者: from xpra.log.Logger import info [as 别名]
def start_pulseaudio(child_reaper, pulseaudio_command):
    from xpra.log import Logger

    log = Logger("sound")
    log("pulseaudio_command=%s", pulseaudio_command)
    pa_proc = subprocess.Popen(pulseaudio_command, stdin=subprocess.PIPE, shell=True, close_fds=True)
    child_reaper.add_process(pa_proc, "pulseaudio", ignore=True)
    log.info("pulseaudio server started with pid %s", pa_proc.pid)

    def check_pa_start():
        if pa_proc.poll() is not None or pa_proc.pid in child_reaper._dead_pids:
            log.warn(
                "Warning: pulseaudio has terminated. Either fix the pulseaudio command line or use --no-pulseaudio to avoid this warning."
            )
            log.warn(
                " usually, only a single pulseaudio instance can be running for each user account, and one may be running already"
            )
        return False

    gobject.timeout_add(1000 * 2, check_pa_start)

    def cleanup_pa():
        log(
            "cleanup_pa() process.poll()=%s, pid=%s, dead_pids=%s", pa_proc.poll(), pa_proc.pid, child_reaper._dead_pids
        )
        if pa_proc.poll() is None and pa_proc.pid not in child_reaper._dead_pids:
            log.info("stopping pulseaudio with pid %s", pa_proc.pid)
            try:
                # first we try pactl (required on Ubuntu):
                from xpra.scripts.exec_util import safe_exec

                r, _, _ = safe_exec(["pactl", "exit"])
                # warning: pactl will return 0 whether it succeeds or not...
                # but we can't kill the process because Ubuntu starts a new one
                if r != 0:
                    # fallback to using SIGINT:
                    pa_proc.terminate()
            except:
                log.warn("error trying to stop pulseaudio", exc_info=True)

    _cleanups.append(cleanup_pa)
开发者ID:svn2github,项目名称:Xpra,代码行数:43,代码来源:server.py

示例10: main

# 需要导入模块: from xpra.log import Logger [as 别名]
# 或者: from xpra.log.Logger import info [as 别名]
def main():
    log = Logger("client")
    from xpra.client.gtk2.tray_menu import GTK2TrayMenu
    client = FakeClient()
    log.info("creating tray menu")
    tray = GTK2TrayMenu(client)
    client.menu = tray.build()
    client.fire_handshake_callbacks()
    log.info("creating tray widget")
    def tray_click(button, pressed, time=0):
        log.info("tray_click(%s, %s, %s)", button, pressed, time)
        if button==1 and pressed:
            glib.idle_add(tray.activate, button, time)
        elif button==3 and not pressed:
            glib.idle_add(tray.popup, button, time)
    def tray_mouseover(*args):
        log.info("tray_mouseover(%s)", args)
    def tray_exit(*args):
        log.info("tray_exit(%s)", args)
        gtk.main_quit()
    def tray_geometry(*args):
        log.info("tray_geometry%s", args)
    GTKStatusIconTray(client, client.menu, "test", None, size_changed_cb=tray_geometry(), click_cb=tray_click, mouseover_cb=tray_mouseover, exit_cb=tray_exit)
    log.info("running main loop")
    gtk.main()
开发者ID:svn2github,项目名称:Xpra,代码行数:27,代码来源:test_gtk2_tray_menu.py

示例11: start_pulseaudio

# 需要导入模块: from xpra.log import Logger [as 别名]
# 或者: from xpra.log.Logger import info [as 别名]
def start_pulseaudio(child_reaper, pulseaudio_command):
    from xpra.log import Logger
    log = Logger("sound")
    log("pulseaudio_command=%s", pulseaudio_command)
    pa_proc = subprocess.Popen(pulseaudio_command, stdin=subprocess.PIPE, shell=True, close_fds=True)
    child_reaper.add_process(pa_proc, "pulseaudio", ignore=True)
    log.info("pulseaudio server started with pid %s", pa_proc.pid)
    def check_pa_start():
        if pa_proc.poll() is not None or pa_proc.pid in child_reaper._dead_pids:
            log.warn("Warning: pulseaudio has terminated. Either fix the pulseaudio command line or use --no-pulseaudio to avoid this warning.")
            log.warn(" usually, only a single pulseaudio instance can be running for each user account, and one may be running already")
        return False
    gobject.timeout_add(1000*2, check_pa_start)
    def cleanup_pa():
        log("cleanup_pa() process.poll()=%s, pid=%s, dead_pids=%s", pa_proc.poll(), pa_proc.pid, child_reaper._dead_pids)
        if pa_proc.poll() is None and pa_proc.pid not in child_reaper._dead_pids:
            log.info("stopping pulseaudio with pid %s", pa_proc.pid)
            try:
                pa_proc.terminate()
            except:
                log.warn("error trying to stop pulseaudio", exc_info=True)
    _cleanups.append(cleanup_pa)
开发者ID:svn2github,项目名称:Xpra,代码行数:24,代码来源:server.py

示例12: main

# 需要导入模块: from xpra.log import Logger [as 别名]
# 或者: from xpra.log.Logger import info [as 别名]
def main():
    from xpra.log import Logger
    log = Logger("util")
    sp = sys.platform
    log.info("platform_name(%s)=%s", sp, platform_name(sp, ""))
    log.info("get_machine_id()=%s", get_machine_id())
    log.info("get_hex_uuid()=%s", get_hex_uuid())
    log.info("get_int_uuid()=%s", get_int_uuid())
开发者ID:svn2github,项目名称:Xpra,代码行数:10,代码来源:os_util.py

示例13: main

# 需要导入模块: from xpra.log import Logger [as 别名]
# 或者: from xpra.log.Logger import info [as 别名]
def main():
    import sys
    from xpra.platform import program_context, command_error
    with program_context("Webcam", "Webcam"):
        from xpra.log import Logger, add_debug_category
        log = Logger("webcam")
        if "-v" in sys.argv or "--verbose" in sys.argv:
            add_debug_category("webcam")
            log.enable_debug()
        try:
            import cv2
        except ImportError as e:
            command_error("Error: no opencv support module: %s" % e)
            return 1
        device = 0
        if len(sys.argv)==2:
            try:
                device = int(sys.argv[1])
            except:
                command_error("Warning: failed to parse value as a device number: '%s'" % sys.argv[1])
        try:
            cap = cv2.VideoCapture(device)
        except Exception as e:
            command_error("Error: failed to capture video using device %s:\n%s" % (device, e))
            return 1
        log.info("capture device for %i: %s", device, cap)
        while True:
            ret, frame = cap.read()
            if not ret:
                command_error("Error: frame capture failed using device %s" % device)
                return 1
            cv2.imshow('frame', frame)
            if cv2.waitKey(10) & 0xFF in (ord('q'), 27):
                break
        cap.release()
        cv2.destroyAllWindows()
        return 0
开发者ID:ljmljz,项目名称:xpra,代码行数:39,代码来源:show_webcam.py

示例14: main

# 需要导入模块: from xpra.log import Logger [as 别名]
# 或者: from xpra.log.Logger import info [as 别名]
def main():
    import logging
    logging.basicConfig(format="%(asctime)s %(message)s")
    logging.root.setLevel(logging.INFO)
    from xpra.log import Logger
    log = Logger("")
    sp = sys.platform
    log.info("platform_name(%s)=%s", sp, platform_name(sp, ""))
    log.info("get_machine_id()=%s", get_machine_id())
    log.info("get_hex_uuid()=%s", get_hex_uuid())
    log.info("get_int_uuid()=%s", get_int_uuid())
开发者ID:Brainiarc7,项目名称:xpra,代码行数:13,代码来源:os_util.py

示例15: do_log_screen_sizes

# 需要导入模块: from xpra.log import Logger [as 别名]
# 或者: from xpra.log.Logger import info [as 别名]
def do_log_screen_sizes(root_w, root_h, sizes):
    from xpra.log import Logger
    log = Logger()
    #old format, used by some clients (android):
    if len(sizes)==2 and type(sizes[0])==int and type(sizes[1])==int:
        return
    for s in sizes:
        if len(s)<10:
            log.info(" %s", s)
            continue
        #more detailed output:
        display_name, width, height, width_mm, height_mm, \
        monitors, work_x, work_y, work_width, work_height = s[:11]
        #always log plug name:
        info = ["'%s'" % prettify_plug_name(display_name)]
        if width!=root_w or height!=root_h:
            #log plug dimensions if not the same as display (root):
            info.append("%sx%s" % (width, height))
        info.append("(%sx%s mm)" % (width_mm, height_mm))
        if work_width!=width or work_height!=height or work_x!=0 or work_y!=0:
            #log workarea if not the same as plug size:
            info.append("workarea: %sx%s" % (work_width, work_height))
            if work_x!=0 or work_y!=0:
                #log position if not (0, 0)
                info.append("at %sx%s" % (work_x, work_y))
        log.info("  "+" ".join(info))
        i = 0
        for m in monitors:
            i += 1
            if len(m)<7:
                log.info("    %s", m)
                continue
            plug_name, plug_x, plug_y, plug_width, plug_height, plug_width_mm, plug_height_mm = m[:8]
            info = ['%s' % prettify_plug_name(plug_name, "monitor %s" % i)]
            if plug_width!=width or plug_height!=height or plug_x!=0 or plug_y!=0:
                info.append("%sx%s" % (plug_width, plug_height))
                if plug_x!=0 or plug_y!=0:
                    info.append("at %sx%s" % (plug_x, plug_y))
            if (plug_width_mm!=width_mm or plug_height_mm!=height_mm) and (plug_width_mm>0 or plug_height_mm>0):
                info.append("(%sx%s mm)" % (plug_width_mm, plug_height_mm))
            log.info("    "+" ".join(info))
开发者ID:svn2github,项目名称:Xpra,代码行数:43,代码来源:util.py


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