Created on Aug 4, 2014 @author: chenshunzi ''' import cmd import optparse import logging from db.db2.api import DB2 from lang.error import tb_to_stdout from utils.logging_utils import config_logging from functools import wraps config_logging('rowlevelsec.log') LOG = logging.getLogger(__name__) def get_parser(): parser = optparse.OptionParser(usage=''' Data generator based on existing data. ''') parser.add_option('-c', '--connection', action='store', type='string', dest='conn', help='connection information, example: KBMASTER|10.98.0.192|60005|db2inst4|password') parser.add_option('-s', '--schema', action='store', type='string', dest='schema', help='default schema') return parser def decode_under_windows_cmd(v):
''' Created on Sep 15, 2014 @author: chenshunzi ''' import os import logging import optparse from utils.logging_utils import config_logging config_logging('classpath_gen.log') LOG = logging.getLogger(__name__) class NotValidDirectory(Exception): pass def generate(target_d, sep='\n'): if not os.path.isdir(target_d): raise NotValidDirectory(target_d) jars = [] for f in os.listdir(target_d): if f.endswith('.jar'): jars.append(f) s = '' for jar in jars:
@author: chenshunzi ''' import cmd import optparse import logging from collections import defaultdict from datetime import datetime from db.db2.api import DB2, Metadata from utils.cmd import get_input, yes_or_no, get_completer from lang.error import tb_to_stdout from utils.logging_utils import config_logging config_logging('gen.log') LOG = logging.getLogger(__name__) DATE_FORMAT = '%Y-%m-%d %H:%M:%S' strptime = datetime.strptime def get_parser(): parser = optparse.OptionParser(usage=''' Data generator based on existing data. ''') parser.add_option('-c', '--connection', action='store', type='string', dest='conn', help='connection information, example: KBMASTER|10.98.0.192|60005|db2inst4|password') return parser class DataCopier(object):
''' Created on Sep 3, 2014 @author: chenshunzi ''' import os import logging import optparse from utils.logging_utils import config_logging config_logging('copy_configuration.log') LOG = logging.getLogger(__name__) CHOOSEN = ['.externalToolBuilders', '.settings', '.classpath', '.project'] EXCLUDE_PROJECTS = ['.metadata', 'Project_Setting_Sharing', 'RemoteSystemsTempFiles', 'Servers'] def get_parser(): parser = optparse.OptionParser(usage=''' Utility for copying eclipse project configuration files. ''') parser.add_option('-s', '--source', action='store', type='string', dest='src', help='source folder') parser.add_option('-d', '--dest', action='store', type='string', dest='dest', help='destination folder') parser.add_option('-c', '--copy', action='store_true', dest='copy', help='perform copy operation') parser.add_option('-b', '--backup', action="store_true", dest='backup',
# -*- coding: utf-8 -*- ''' Created on May 23, 2014 @author: chenshunzi ''' import subprocess import logging from utils.logging_utils import config_logging from remote.ssh import SSH config_logging('deploy_app.log') LOG = logging.getLogger(__name__) sso_host = SSH('60.12.204.146', 61022, 'root', 'Shun^Zi[001]*') baton_host = SSH('183.136.128.59', 61122, 'root', 'Smart^Logis[008]*') def run_local(cmd): LOG.debug('run local command: %s' % cmd) Popen = subprocess.Popen task = Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) return task.stdout.read()
@author: Administrator ''' import eventlet import eventlet.wsgi import sys import webob import utils.logging_utils as logging_utils import logging from routes import Mapper from pprint import pprint logging_utils.config_logging("/home/openstack/logs/myserver.log") LOG = logging.getLogger(__name__) def import_module(path): __import__(path) return sys.modules[path] def dispatch(environ, start_response): ''' Main serving routine for web server. ''' # URL matching result = mapper.match(environ['PATH_INFO'])