def _prepare_logfiles(self): from stoqlib.lib.osutils import get_application_dir stoqdir = get_application_dir("stoq") log_dir = os.path.join(stoqdir, 'logs', time.strftime('%Y'), time.strftime('%m')) if not os.path.exists(log_dir): os.makedirs(log_dir) filename = 'stoq_%s.%s.log' % (time.strftime('%Y-%m-%d_%H-%M-%S'), os.getpid()) self._log_filename = os.path.join(log_dir, filename) from kiwi.log import set_log_file self._stream = set_log_file(self._log_filename, 'stoq*') if platform.system() != 'Windows': link_file = os.path.join(stoqdir, 'stoq.log') if os.path.exists(link_file): os.unlink(link_file) os.symlink(self._log_filename, link_file) # We want developers to see deprecation warnings. from stoqlib.lib.environment import is_developer_mode if is_developer_mode(): import warnings if self._options.non_fatal_warnings: action = "default" else: action = "error" warnings.filterwarnings(action, category=DeprecationWarning, module="^(stoq|kiwi)")
def _prepare_logfiles(self): from stoqlib.lib.osutils import get_application_dir stoqdir = get_application_dir("stoq") log_dir = os.path.join(stoqdir, 'logs', time.strftime('%Y'), time.strftime('%m')) if not os.path.exists(log_dir): os.makedirs(log_dir) self._log_filename = os.path.join(log_dir, 'stoq_%s.log' % time.strftime('%Y-%m-%d_%H-%M-%S')) from kiwi.log import set_log_file self._stream = set_log_file(self._log_filename, 'stoq*') if hasattr(os, 'symlink'): link_file = os.path.join(stoqdir, 'stoq.log') if os.path.exists(link_file): os.unlink(link_file) os.symlink(self._log_filename, link_file) # We want developers to see deprecation warnings. from stoqlib.lib.environment import is_developer_mode if is_developer_mode(): import warnings warnings.filterwarnings( "default", category=DeprecationWarning, module="^(stoq|kiwi)")
def _prepare_logfiles(self): from stoqlib.lib.osutils import get_application_dir stoqdir = get_application_dir("stoq") log_dir = os.path.join(stoqdir, 'logs', time.strftime('%Y'), time.strftime('%m')) if not os.path.exists(log_dir): os.makedirs(log_dir) self._log_filename = os.path.join( log_dir, 'stoq_%s.log' % time.strftime('%Y-%m-%d_%H-%M-%S')) from kiwi.log import set_log_file self._stream = set_log_file(self._log_filename, 'stoq*') if hasattr(os, 'symlink'): link_file = os.path.join(stoqdir, 'stoq.log') if os.path.exists(link_file): os.unlink(link_file) os.symlink(self._log_filename, link_file) # We want developers to see deprecation warnings. from stoqlib.lib.environment import is_developer_mode if is_developer_mode(): import warnings warnings.filterwarnings("default", category=DeprecationWarning, module="^(stoq|kiwi)")
def _prepare_logfiles(self): from stoqlib.lib.osutils import get_application_dir stoqdir = get_application_dir("stoq") log_dir = os.path.join(stoqdir, 'logs', time.strftime('%Y'), time.strftime('%m')) if not os.path.exists(log_dir): os.makedirs(log_dir) filename = 'stoq_%s.%s.log' % (time.strftime('%Y-%m-%d_%H-%M-%S'), os.getpid()) self._log_filename = os.path.join(log_dir, filename) from kiwi.log import set_log_file self._stream = set_log_file(self._log_filename, 'stoq*') if platform.system() != 'Windows': link_file = os.path.join(stoqdir, 'stoq.log') if os.path.exists(link_file): os.unlink(link_file) os.symlink(self._log_filename, link_file) # We want developers to see deprecation warnings. from stoqlib.lib.environment import is_developer_mode if is_developer_mode() and not self._options.quiet: import warnings if self._options.non_fatal_warnings: action = "default" else: action = "error" warnings.filterwarnings( action, category=DeprecationWarning, module="^(stoq|kiwi)")
def setup_logging(appname): from stoqlib.lib.osutils import get_application_dir stoqdir = get_application_dir(appname) log_dir = os.path.join(stoqdir, 'logs', time.strftime('%Y'), time.strftime('%m')) if not os.path.exists(log_dir): os.makedirs(log_dir) from kiwi.log import set_log_file _log_filename = os.path.join(log_dir, 'stoq_%s.log' % time.strftime('%Y-%m-%d_%H-%M-%S')) _stream = set_log_file(_log_filename, 'stoq*') if hasattr(os, 'symlink'): link_file = os.path.join(stoqdir, 'stoq.log') if os.path.exists(link_file): os.unlink(link_file) os.symlink(_log_filename, link_file) return _log_filename, _stream
pythonpath.insert(1, guidir) pythonpath.insert(2, resdir) # Initializing logger import logging from lib.path import path as Path from kiwi.log import set_log_file from os import environ log = logging.getLogger('Runner') homedir = Path(__file__).getcwd() LOG_FILE = Path.joinpath(homedir, 'packagehelper.log') if not LOG_FILE.exists(): print "Creating log file" LOG_FILE.touch() environ['PKG_LOGFILE'] = str(LOG_FILE) set_log_file(LOG_FILE, '*') log.info("Logger started") # Checking parameters if "--help" in argv[:]: print "Usage: " + __file__ + " [OPTION]" print """\nCheckout files from CVS using the given tags and create the execution scripts for *.sql files. The files are expected to have a directory tree like './<BD>/<USERNAME>/<TYPE>/script.sql' OPTIONS: --no-gui Do not use graphical user interface.""" from package.gui.filechooser import FileChooser class Teste: propriedade = None
self.cvs.export(self.test_data_dir, self.tag) # Two command should run when exporting from cvs: login and export self.assertEquals(len(self.runner.commands), 2) expected = "cvsmock -q -z 9 export -d %s -r %s %s" % (self.tag, self.tag, self.module) actual = self.runner.commands[1] self.assertEquals(expected, actual) if __name__ == "__main__": # Initializing PythonPath localdir = path.dirname(path.abspath(__file__)) ph_home = path.join(localdir, "../../../") pythonpath.insert(0, ph_home) ph_lib = path.join(ph_home, "lib") pythonpath.insert(1, ph_lib) ph_test = path.join(ph_home, "test") pythonpath.insert(2, ph_test) from framework import TestCase # Setting up Logger from kiwi.log import set_log_file set_log_file("Tests.log") #unittest.main() suite = unittest.TestLoader().loadTestsFromTestCase(CvsTest) unittest.TextTestRunner(verbosity=2).run(suite)
def testSetLogFile(self): set_log_file(self.filename, 'log') self.log.info("sliff") lines = open(self.filename).readlines() self.assertEqual(len(lines), 1) self.failUnless('sliff' in lines[0])