Пример #1
0
 def test_start_logger(self):
     fd, name = tempfile.mkstemp()
     os.close(fd)
     defl = start_logger(log_to_file=True, log_filename=name)
     assert defl is None
     log = getLogger()
     log.error("at error level")
     fh = open(name)
     fh.seek(0)
     assert fh.read().endswith('[root] - at error level\n')
     log.info("at info level")
     fh.seek(0)
     lines = fh.readlines()
     assert lines[1].endswith('[root] - at info level\n')
Пример #2
0
 def test_start_logger(self):
     fd, name = tempfile.mkstemp()
     os.close(fd)
     defl = start_logger(log_to_file=True, log_filename=name)
     assert defl is None
     log = getLogger()
     log.error("at error level")
     fh = open(name)
     fh.seek(0)
     assert fh.read().endswith('[root] - at error level\n')
     log.info("at info level")
     fh.seek(0)
     lines = fh.readlines()
     assert lines[1].endswith('[root] - at info level\n')
Пример #3
0
 \    /
  join (linear)
    |
  print         

"""
# Part 0: import the PaPy infrastructure.
# interface of the API: 
from papy import Plumber, Piper, Worker
from papy.util.func import print_
## the parallel NuMap function and imports wrapper: 
from numap import NuMap, imports
## logging support
import logging
from papy.util.config import start_logger
start_logger(log_to_stream=True, log_to_stream_level=logging.ERROR)


# Part 1: Define user functions
def fork(inbox):
    msg = inbox[0]
    return msg

@imports(['socket', 'os', 'threading'])
def who_am_i(inbox):
    """
    This function identifies the host process.
    """
    return "process:%s" % os.getpid()

def join(inbox):
Пример #4
0
  join (linear)
    |
  print         

"""
# Part 0: import the PaPy infrastructure.
# interface of the API:
from papy import Plumber, Piper, Worker
from papy.util.func import print_
## the parallel NuMap function and imports wrapper:
from numap import NuMap, imports
## logging support
import logging
from papy.util.config import start_logger

start_logger(log_to_stream=True, log_to_stream_level=logging.ERROR)


# Part 1: Define user functions
def fork(inbox):
    msg = inbox[0]
    return msg


@imports(['socket', 'os', 'threading'])
def who_am_i(inbox):
    """
    This function identifies the host process.
    """
    return "process:%s" % os.getpid()