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


Python log.info函数代码示例

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


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

示例1: isMozpoolReady

def isMozpoolReady(device):
    """ Checks if the mozpool server is available and the device is in 'ready' state

    Returns MOZPOOL_STATE_READY if Mozpool is indeed listing device as ready
    Returns MOZPOOL_STATE_UNKNOWN if Mozpool claims the device is in a non-ready state
    Returns MOZPOOL_STATE_ERROR if Mozpool reports some other error.
    Returns MOZPOOL_STATE_MISSING if there is no Mozpool server found in DNS.
    """
    import socket
    default_timeout = socket.getdefaulttimeout()
    socket.setdefaulttimeout(5)  # Don't let networking delay us too long
    try:
        socket.gethostbyname(MOZPOOL_CNAME)
    except:
        log.info("No mozpool server in this VLAN")
        return MOZPOOL_STATE_MISSING
    finally:
        # Set socket timeout back
        socket.setdefaulttimeout(default_timeout)

    mpc = MozpoolHandler("http://%s" % MOZPOOL_CNAME, log)
    try:
        result = mpc.query_device_state(device)
    except MozpoolException as e:
        log.error("Unable to get mozpool state, mozpool returned error: %s" % sys.exc_info()[1])
        return MOZPOOL_STATE_ERROR

    if result['state'] == "ready":
        log.debug("Mozpool state is 'ready'")
        return MOZPOOL_STATE_READY
    else:
        log.error("Mozpool state is '%s'" % result['state'])
        return MOZPOOL_STATE_UNKNOWN
开发者ID:IanConnolly,项目名称:build-tools,代码行数:33,代码来源:verify.py

示例2: checkSDCard

def checkSDCard(dm):
    """ Attempt to write a temp file to the SDCard

    We use this existing verify script as the source of the temp file

    Returns False on failure, True on Success
    """
    if not dmAlive(dm):
        return False

    try:
        if not dm.dirExists("/mnt/sdcard"):
            setFlag(errorFile, "Remote Device Error: Mount of sdcard does not seem to exist")
            return False
        if dm.fileExists("/mnt/sdcard/writetest"):
            log.info("INFO: /mnt/sdcard/writetest left over from previous run, cleaning")
            dm.removeFile("/mnt/sdcard/writetest")
        log.info("INFO: attempting to create file /mnt/sdcard/writetest")
        if not dm.pushFile(os.path.join(os.path.abspath(os.path.dirname(__file__)), "verify.py"), "/mnt/sdcard/writetest"):
            setFlag(
                errorFile, "Remote Device Error: unable to write to sdcard")
            return False
        if not dm.fileExists("/mnt/sdcard/writetest"):
            setFlag(errorFile, "Remote Device Error: Written tempfile doesn't exist on inspection")
            return False
        if not dm.removeFile("/mnt/sdcard/writetest"):
            setFlag(errorFile, "Remote Device Error: Unable to cleanup from written tempfile")
            return False
    except Exception, e:
        setFlag(errorFile, "Remote Device Error: Unknown error while testing ability to write to "
                           "sdcard, see following exception: %s" % e)
        return False
开发者ID:IanConnolly,项目名称:build-tools,代码行数:32,代码来源:verify.py

示例3: main

def main(argv):

    if (len(argv) < 3):
        print "usage: installWatcher.py <ip address> <localfilename>"
        sys.exit(1)

    ip_addr = argv[1]
    path_to_main_apk = argv[2]

    dm = droid.DroidSUT(ip_addr)
    if not dm:
        log.error("could not get device manager!")
        return 1
    devRoot = checkDeviceRoot(dm)

    if install(dm, devRoot, path_to_main_apk, "com.mozilla.watcher"):
        log.error("install failed")
        return 1

    dm.reboot()
    waitForDevice(dm)

    # we can't use the following dm.getFile method, since only Watcher runtime user has read access
    # to this file, so we need to be root to read it, hence the slightly more convoluted version
    # using dm._runCmds below...
    # cannot use -> print dm.getFile('/data/data/com.mozilla.watcher/files/version.txt')
    status = dm._runCmds([{'cmd': 'exec su -c "cat /data/data/com.mozilla.watcher/files/version.txt"'}]).split('\n')
    log.info('Watcher version: %s' % status)
    return 0
开发者ID:petemoore,项目名称:myscrapbook,代码行数:29,代码来源:install_watcher.py

示例4: setWatcherINI

def setWatcherINI(dm):
    """ If necessary Installs the (correct) watcher.ini for our infra

    Returns False on failure, True on Success
    """
    import hashlib
    realLoc = "/data/data/com.mozilla.watcher/files/watcher.ini"
    currentHash = hashlib.md5(watcherINI).hexdigest()

    def watcherDataCurrent():
        remoteFileHash = dm._getRemoteHash(realLoc)
        if currentHash != remoteFileHash:
            return False
        else:
            return True

    if not dmAlive(dm):
        return False

    try:
        if watcherDataCurrent():
            return True
    except:
        setFlag(errorFile, "Unable to identify if watcher.ini is current")
        return False

    tmpname = '/mnt/sdcard/watcher.ini'
    try:
        dm._runCmds([{'cmd': 'push %s %s' % (tmpname, len(
            watcherINI)), 'data': watcherINI}])
    except devicemanager.AgentError, err:
        log.info("Error while pushing watcher.ini: %s" % err)
        setFlag(errorFile, "Unable to properly upload the watcher.ini")
        return False
开发者ID:IanConnolly,项目名称:build-tools,代码行数:34,代码来源:verify.py

示例5: doUpdate

def doUpdate(dm):
    _oldDebug = dm.debug
    log.info("updateSUT.py: We're going to try to install SUTAgentAndroid Version %s" % target_version)
    try:
        data = download_apk()
    except Exception, e:
        log.error("Automation Error: updateSUT.py: We have failed to retrieve the SUT Agent. %s" % str(e))
        return RETCODE_APK_DL_FAILED
开发者ID:magnyld,项目名称:build-tools,代码行数:8,代码来源:updateSUT.py

示例6: download_apk

def download_apk():
    url = 'http://talos-bundles.pvt.build.mozilla.org/mobile/sutAgentAndroid.%s.apk' % target_version
    log.info("INFO: updateSUT.py: We're downloading the apk: %s" % url)
    req = urllib2.Request(url)
    try:
        f = urllib2.urlopen(req)
    except urllib2.URLError, e:
        reason = getattr(e, "reason", "SUT-Undef")
        code = getattr(e, "code", "SUT-Undef")
        raise Exception("Automation Error: updateSUT.py: code: %s; reason: %s" % (code, reason))
开发者ID:magnyld,项目名称:build-tools,代码行数:10,代码来源:updateSUT.py

示例7: checkVersion

def checkVersion(dm, flag=False):
    """ Verify SUTAgent Version

    Returns False on failure, True on Success
    """
    if not dmAlive(dm):
        return False

    ver = updateSUT.version(dm)
    if not updateSUT.isVersionCorrect(ver=ver):
        if flag:
            setFlag(errorFile, "Remote Device Error: Unexpected ver on device, got '%s' expected '%s'" %
                    (ver, "SUTAgentAndroid Version %s" % updateSUT.target_version))
        return False
    log.info(
        "INFO: Got expected SUTAgent version '%s'" % updateSUT.target_version)
    return True
开发者ID:IanConnolly,项目名称:build-tools,代码行数:17,代码来源:verify.py

示例8: cleanupDevice

def cleanupDevice(device=None, dm=None):
    assert ((device is not None) or (dm is not None))  # Require one to be set

    if not device:
        device = os.environ['SUT_NAME']
    pidDir = os.path.join('/builds/', device)
    errorFile = os.path.join(pidDir, 'error.flg')
    reboot_needed = False

    processNames = ['org.mozilla.fennec_aurora',
                    'org.mozilla.fennec_unofficial',
                    'org.mozilla.fennec',
                    'org.mozilla.firefox_beta',
                    'org.mozilla.firefox',
                    'org.mozilla.roboexample.test',
                    ]

    if dm is None:
        log.info("Connecting to: " + device)
        dm = devicemanager.DeviceManagerSUT(device)
        dm.debug = 5

    packages = dm._runCmds([{'cmd': 'exec pm list packages'}])
    for package in packages.split('\n'):
        if not package.strip().startswith("package:"):
            continue  # unknown entry
        package_basename = package.strip()[8:]
        for proc in processNames:
            if package_basename == "%s" % proc or \
                    package_basename.startswith("%s_" % proc):
                log.info("Uninstalling %s..." % package_basename)
                try:
                    if 'panda' in device:
                        dm.uninstallApp(package_basename)
                        reboot_needed = True
                    else:
                        dm.uninstallAppAndReboot(package_basename)
                        waitForDevice(dm)
                except devicemanager.DMError, err:
                    setFlag(errorFile,
                            "Remote Device Error: Unable to uninstall %s and reboot: %s" % (package_basename, err))
                    return RETCODE_ERROR
                finally:
                    break  # Don't try this proc again, since we already matched
开发者ID:B-Rich,项目名称:build-tools,代码行数:44,代码来源:cleanup.py

示例9: canPing

def canPing(device):
    """ Check a device is reachable by ping

    Returns False on failure, True on Success
    """
    curRetry = 0
    log.info("INFO: attempting to ping device")
    while curRetry < MAX_RETRIES:
        ret, _ = pingDevice(device)
        if not ret:
            curRetry += 1
            if curRetry == MAX_RETRIES:
                setFlag(errorFile, "Automation Error: Unable to ping device after %s attempts" % MAX_RETRIES)
                return False
            else:
                log.info("INFO: Unable to ping device after %s try. Sleeping for 90s then retrying" % curRetry)
                time.sleep(90)
        else:
            break  # we're done here
    return True
开发者ID:IanConnolly,项目名称:build-tools,代码行数:20,代码来源:verify.py

示例10: main

def main(argv):

    if len(argv) < 2:
        print "usage: installWatcher.py <ip address>"
        sys.exit(1)

    ip_addr = argv[1]

    dm = droid.DroidSUT(ip_addr)
    if not dm:
        log.error("could not get device manager!")
        return 1
    devRoot = checkDeviceRoot(dm)

    # we can't use the following dm.getFile method, since only Watcher runtime user has read access
    # to this file, so we need to be root to read it, hence the slightly more convoluted version
    # using dm._runCmds below...
    # cannot use -> print dm.getFile('/data/data/com.mozilla.watcher/files/version.txt')
    status = dm._runCmds([{"cmd": 'exec su -c "cat /data/data/com.mozilla.watcher/files/version.txt"'}]).split("\n")
    log.info("Watcher version: %s" % status)
    return 0
开发者ID:petemoore,项目名称:myscrapbook,代码行数:21,代码来源:watcher_version.py

示例11: installOneApp

def installOneApp(dm, devRoot, app_file_local_path, errorFile, logcat=True):

    source = app_file_local_path
    filename = os.path.basename(source)
    target = os.path.join(devRoot, filename)

    log.info("Installing %s" % target)
    if dm.pushFile(source, target):
        status = dm.installApp(target)
        if status is None:
            log.info('-' * 42)
            log.info('installApp() done - gathering debug info')
            dm.getInfo('process')
            dm.getInfo('memory')
            dm.getInfo('uptime')
            if logcat:
                try:
                    print dm._runCmds([{'cmd': 'exec su -c "logcat -d -v time *:W"'}])
                except devicemanager.DMError, e:
                    setFlag(errorFile, "Remote Device Error: Exception hit while trying to run logcat: %s" % str(e))
                    return 1
        else:
            setFlag(errorFile,
                    "Remote Device Error: updateApp() call failed - exiting")
            return 1
开发者ID:B-Rich,项目名称:build-tools,代码行数:25,代码来源:installApp.py

示例12: smoketest

def smoketest(device_name, number):
    global dm
    global appFileName, processName

    dm = devicemanager.DeviceManagerSUT(device_name, 20701)
    deviceRoot = dm.getDeviceRoot()

    # This does all the steps of verify.py including the cleanup.
    if verifyDevice(device_name, checksut=False, doCheckStalled=False) is False:
        log.error("failed to run verify on %s" % (device_name))
        return 1  # Not ok to proceed
    log.info("Successfully verified the device")

    if dm._sock:
        dm._sock.close()
    time.sleep(30)
    dm = devicemanager.DeviceManagerSUT(device_name, 20701)
    print "in smoketest, going to call installOneApp with dm: %s, %s" \
          % (dm, dm._sock)
    if installOneApp(dm, deviceRoot, os.path.abspath(appFileName), None, logcat=False):
        log.error("failed to install %s on device %s" % (appFileName, device_name))
        return 1
    log.info("Successfully installed the application")

    if not runTests(device_name, processName, number):
        log.error("failed to run dom tests on %s" % (device_name))
        return 1
    log.info("Successfully ran the mochitests")
    return 0
开发者ID:Callek,项目名称:build-tools,代码行数:29,代码来源:smoketest.py

示例13: install

def install(dm, devRoot, app_file_local_path, package):
    source = app_file_local_path
    filename = os.path.basename(source)
    target = os.path.join(devRoot, filename)

    log.info("Pushing new apk to the device: %s" % target)
    status = dm.pushFile(source, target)

    dm.shellCheckOutput(["dd", "if=%s" % target, "of=/data/local/watcher.apk"], root=True)
    dm.shellCheckOutput(["chmod", "666", "/data/local/watcher.apk"], root=True)

    log.info("Uninstalling %s" % package)
    try:
        dm.uninstallApp(package)
        log.info('uninstallation successful')
    except devicemanager.DMError, e:
        log.info('uninstallation failed -- maybe not installed? '+str(e))
开发者ID:petemoore,项目名称:myscrapbook,代码行数:17,代码来源:install_watcher.py

示例14: main

def main(argv):
    global ip_addr

    if (len(argv) < 4):
        log.info("usage: logcat.py <device ip address> <output filename> <logcat options>")
        return 1
    ip_addr = argv[1]
    output_filename = argv[2]
    logcat_options = argv[3]
    max_runtime = 3600   # 3600 seconds == 1 hour

    status = 0
    dm = devicemanager.DeviceManagerSUT(ip_addr)
    if not dm:
        log.error("logcat.py: unable to open device manager")
        return 2
    command = 'execext su t=%d logcat %s' % (max_runtime, logcat_options)
    log.debug('logcat.py running SUT command: %s' % command)
    try:
        with open(output_filename, 'w') as f:
            dm._sendCmds([{'cmd': command}], f)
    except devicemanager.DMError, e:
        log.error("Remote Device Error: Exception caught running logcat: %s" % str(e))
        status = -1
开发者ID:B-Rich,项目名称:build-tools,代码行数:24,代码来源:logcat.py

示例15: canTelnet

def canTelnet(device):
    """ Checks if we can establish a Telnet session (via devicemanager)

    Sets global `dm`
    Returns False on failure, True on Success
    """
    global dm
    curRetry = 0
    sleepDuration = 0
    while curRetry < MAX_RETRIES:
        try:
            dm = connect(device, sleepDuration)
        except:
            curRetry += 1
            if curRetry == MAX_RETRIES:
                setFlag(errorFile, "Automation Error: Unable to connect to device after %s attempts" % MAX_RETRIES)
                return False
            else:
                log.info("INFO: Unable to connect to device after %s try" %
                         curRetry)
                sleepDuration = 90
        else:
            break  # We're done here
    return True
开发者ID:IanConnolly,项目名称:build-tools,代码行数:24,代码来源:verify.py


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