Exemplo n.º 1
0
#!/usr/bin/env python

import collections
import logging
import module
import logstash

logging.basicConfig(filename='./example.log', level=logging.DEBUG)
logging.debug('this is a debug message')
logging.info('this is an info message')
logging.warning('this is a warning message')
logging.error('this is an error message')

logger = logging.getLogger(__name__)
logger.debug('using a named logger')
module.func()

fh = logging.FileHandler('separate.log')
logger = logging.getLogger('separate')
logger.propagate = False
logger.addHandler(fh)
logger.debug('separate')

logstash.debug(logger, logstash.Log(key='hi'))
Exemplo n.º 2
0
from module import func
from MyMainPackage import main_script
from MyMainPackage.SubPackageOne import subscriptOne
func()
main_script.reportmain()
subscriptOne.subReport()
Exemplo n.º 3
0
import module


def funct():
    print("hello")
    module.pra()


funct()
module.func("prabeena")
Exemplo n.º 4
0
# import

## import
import module

assert module.name == 'module'
assert module.func(10) == 10
assert module.func_2(10) == 20
assert module.Module('first').name == 'first'
assert module.module_2.func(10) == 100
assert module.module_2.func_2(10) == 200


## import as
import module as new_module

assert new_module.func(10) == 10
assert new_module.func_2(10) == 20


## import and import as
import module, module_2 as new_module_2

assert module.func(10) == 10
assert module.func_2(10) == 20

assert new_module_2.func(10) == 100
assert new_module_2.func_2(10) == 200

## multi import as
import module as new_module, module_2 as new_module_2
 def wrapped_function():
   return "Wrapped: {}".format(func())
Exemplo n.º 6
0
#import
import module
module.function1('wow')

#named import
import module as mod
mod.function1('wow2')

#nmaed binding import
from module import function1 as func
func('wow3')