Beispiel #1
0
def showLogs(logLevel=7, color=True):
    """
    A contextmanager that returns a usable logger that is configured
    to log debug output.
    """
    from OPSI.Logger import Logger

    logger = Logger()

    logLevelBefore = logger.getConsoleLevel()

    # We might want to have a better log format:
    # logger.setLogFormat(u'[%l] [%D] %M (%F|%N)')

    try:
        logger.setConsoleLevel(logLevel)
        logger.setConsoleColor(color)
        yield logger
    finally:
        logger.setConsoleLevel(logLevelBefore)
Beispiel #2
0
		values = getHardwareInformationFromExecuteCommand(config, values)

		logger.info(u"Hardware information from WMI:\n%s" % objectToBeautifiedText(values))
		auditHardwareOnHosts = []
		for hardwareClass, devices in values.items():
			if hardwareClass == 'SCANPROPERTIES':
				continue

			for device in devices:
				data = {str(attribute): value for attribute, value in device.items()}
				data['hardwareClass'] = hardwareClass
				data['hostId'] = host_id

				auditHardwareOnHosts.append(AuditHardwareOnHost.fromHash(data))

		logger.info(u"Obsoleting old hardware audit data")
		backend.auditHardwareOnHost_setObsolete(host_id)
		logger.notice(u"Sending hardware information to service")
		backend.auditHardwareOnHost_updateObjects(auditHardwareOnHosts)

	logger.notice(u"Exiting...")


if __name__ == "__main__":
	logger.setConsoleLevel(LOG_ERROR)
	try:
		main(sys.argv[1:])
	except Exception as error:
		logger.logException(error)
		sys.exit(1)
Beispiel #3
0
    #jsonrpc1 = JSONRPC(jsonrpcBackend = be, baseUrl = be._baseUrl, method = 'authenticated', params = [], retry = False)
    be.authenticated().setCallback(callback)
    #jsonrpc2 = JSONRPC(jsonrpcBackend = be, baseUrl = be._baseUrl, method = 'group_getIdents', params = [], retry = False)
    be.group_getIdents().setCallback(callback)
    #jsonrpc3 = JSONRPC(jsonrpcBackend = be, baseUrl = be._baseUrl, method = 'host_getIdents', params = [], retry = False)
    be.host_getIdents().setCallback(callback)
    be.host_getIdents().setCallback(callback)
    be.host_getIdents().setCallback(callback)
    be.host_getIdents().setCallback(callback)
    be.host_getIdents().setCallback(callback)

    be.setAsync(False)
    print("===", be.host_getIdents())

    be.backend_exit()


def main():
    checkIfMultipleCallsSucceed()
    checkIfConnectionWithCertWorks()
    checkAsynchronosProcessing()


if __name__ == '__main__':

    logger.setConsoleLevel(LOG_INFO)
    logger.setConsoleColor(True)

    main()
Beispiel #4
0
    fileBackend.config_createObjects(mysqlBackend.config_getObjects())
    fileBackend.configState_createObjects(
        mysqlBackend.configState_getObjects())
    fileBackend.product_createObjects(mysqlBackend.product_getObjects())
    fileBackend.productProperty_createObjects(
        mysqlBackend.productProperty_getObjects())
    fileBackend.productDependency_createObjects(
        mysqlBackend.productDependency_getObjects())
    fileBackend.productOnDepot_createObjects(
        mysqlBackend.productOnDepot_getObjects())
    fileBackend.productOnClient_createObjects(
        mysqlBackend.productOnClient_getObjects())
    fileBackend.productPropertyState_createObjects(
        mysqlBackend.productPropertyState_getObjects())
    fileBackend.group_createObjects(mysqlBackend.group_getObjects())
    fileBackend.objectToGroup_createObjects(
        mysqlBackend.objectToGroup_getObjects())

    check('mysqlBackend', 'fileBackend')

    print("-------------------------------------")
    print("- seem to work ... all tests passed -")
    print("-------------------------------------")


if __name__ == '__main__':
    logger.setConsoleLevel(LOG_DEBUG)
    logger.setConsoleColor(True)

    main()
Beispiel #5
0
                        })
    LOGGER.notice(resp.data)
    resp = pool.urlopen('GET',
                        url='/www/home/index.html',
                        body=None,
                        headers={
                            "accept": "text/html",
                            "user-agent": "test"
                        })
    LOGGER.notice(resp.headers)
    resp = pool.urlopen('GET',
                        url='/www/home/index.html',
                        body=None,
                        headers={
                            "accept": "text/html",
                            "user-agent": "test"
                        })
    LOGGER.notice(resp.data)
    LOGGER.notice(resp.headers)
    LOGGER.notice(resp.status)
    LOGGER.notice(resp.version)
    LOGGER.notice(resp.reason)
    LOGGER.notice(resp.strict)


if __name__ == '__main__':
    LOGGER.setConsoleLevel(LOG_DEBUG)
    LOGGER.setConsoleColor(True)

    main()