コード例 #1
0
def main():
    loop = True
    while loop:
        print("\n")
        print("-" * 70)
        print("종료하실려면 q나 -1를 입력해 주세용.")
        print("-" * 70)
        input_num = input("로그파일 명을 입력해주세요. : ")
        if input_num == "q" :
            print("종료되었습니다.^^")
            loop = False
        elif len(input_num) > 0:   
            __loop__ = True
            while __loop__:  
                print("=" * 70)
                print("단어종료를 하실려면 q나 -1를 입력해 주세용.")
                input_keyword = input("찾을 단어를 입력해 주세요. : ")
                if input_keyword == "q":
                    print("파일명 찾기로 이동합니당^^")
                    __loop__ = False
                elif len(input_keyword) > 0:    
                    mylog.printlog(input_num, input_keyword, 0, 3, 5)
                else:
                    print("단어를 입력해 주세용^^.....")
        else:
            print("파일명을 입력해 주세용....")
コード例 #2
0
def main():
    # Internal functions to main()
    def terminate(exitcode):
        log.error('program terminated prematurely... good bye')
        sys.exit(exitcode)

    # Main program code starts here
    try:
        # Gather and verify command line arguments
        args = getopts.vdeploy_options()

        # Start Logging
        log = mylog.logg('vDeploy',
                         llevel=args.log,
                         lfile=args.logfile,
                         cnsl=args.console)
        log.info('program start : %s' % args)

        # Load the Hypervisor, VM and Network Definition Files (YAML data structure templates)
        try:
            ddf_context = provisioning.DDFContext(args)
        except provisioning.DDFLoadError, err:
            mylog.printlog(log,
                           "Descriptor configuration file not found: %s" % err,
                           'ERROR')
            terminate(1)

        # See if we are going to run as a service
        if args.daemonize:
            try:
                daemon_handle = vdeploy_server.Server(args, ddf_context)
            except vdeploy_server.DaemonError:
                mylog.printlog(log, "Could not start as a service, exiting")
                terminate(1)
        else:
            # We're running on the command line, process the deployment definition
            # files and create the data structures to hand off to the deployment engine
            try:
                ddf_context.process_ddf_files(args)
            except provisioning.DDFLoadError, err:
                mylog.printlog(log,
                               "Error processing description file: %s" % err)
                terminate(1)
            # Now that the context has the deployment structure instantiated, send it off
            # to the execution engine for deployment, Deploy returns immediately, you must
            # check status to determine whether the deployment has actually completed
            try:
                deploy_context = deployment.Deploy(ddf_context, args)
                while deploy_context.status() == "executing":
                    continue

            except deployment.DeployExecError, err:
                mylog.printlog(log, "Deploy Failed: %s" % err, 'ERROR')
                terminate(1)
コード例 #3
0
ファイル: vdeploy.py プロジェクト: l0r3zz/vDeploy
def main():
    # Internal functions to main()
    def terminate(exitcode):
        log.error('program terminated prematurely... good bye')
        sys.exit(exitcode)
    # Main program code starts here
    try:
        # Gather and verify command line arguments
        args = getopts.vdeploy_options()

        # Start Logging
        log = mylog.logg('vDeploy',llevel=args.log,
                          lfile=args.logfile,cnsl=args.console)
        log.info('program start : %s' % args)

        # Load the Hypervisor, VM and Network Definition Files (YAML data structure templates)
        try:
            ddf_context = provisioning.DDFContext(args)
        except provisioning.DDFLoadError, err:
            mylog.printlog(log,"Descriptor configuration file not found: %s" % err, 'ERROR')
            terminate(1)

        # See if we are going to run as a service
        if args.daemonize :
            try:
                daemon_handle = vdeploy_server.Server(args,ddf_context)
            except vdeploy_server.DaemonError:
                mylog.printlog(log,"Could not start as a service, exiting")
                terminate(1)
        else:
            # We're running on the command line, process the deployment definition
            # files and create the data structures to hand off to the deployment engine
            try:
                ddf_context.process_ddf_files(args)
            except provisioning.DDFLoadError, err:
                mylog.printlog(log,"Error processing description file: %s" % err)
                terminate(1)
            # Now that the context has the deployment structure instantiated, send it off
            # to the execution engine for deployment, Deploy returns immediately, you must
            # check status to determine whether the deployment has actually completed
            try:
                deploy_context = deployment.Deploy(ddf_context,args)
                while deploy_context.status() == "executing":
                    continue

            except deployment.DeployExecError, err:
                mylog.printlog(log,"Deploy Failed: %s" % err, 'ERROR')
                terminate(1)
コード例 #4
0
    def __init__(self, args):

        log.info("Starting config file processing")

        # Scan for presence of config directory
        config_dir = './'
        for dpath in CONFIG_DIR_DEFAULTS:
            if os.path.exists(dpath):
                config_dir = dpath
                break
        self.ddfdict = {}
        # Attempt to load all of the data structure temple definitions
        try:
            self.hvpath = config_dir + HVDEF_TEMPLATE
            if os.path.exists(self.hvpath):
                self.hvtemplate = yaml.load(file(self.hvpath))
                self.ddfdict['hdf'] = self.hvpath
                if not self.hvtemplate:
                    mylog.printlog(log, "%s is empty" % self.hvpath, 'INFO')
            else:
                raise DDFLoadError(self.hvpath)

            self.vmpath = config_dir + VMDEF_TEMPLATE
            if os.path.exists(self.vmpath):
                self.vmtemplate = yaml.load(file(self.vmpath))
                self.ddfdict['vdf'] = self.vmpath
                if not self.vmtemplate:
                    mylog.printlog(log, "%s is empty" % self.vmpath, 'INFO')
            else:
                raise DDFLoadError(self.vmpath)

            self.netpath = config_dir + NETDEF_TEMPLATE
            if os.path.exists(self.netpath):
                self.nettemplate = yaml.load(file(self.netpath))
                self.ddfdict['ndf'] = self.netpath
                if not self.nettemplate:
                    mylog.printlog(log, "%s is empty" % self.netpath, 'INFO')
            else:
                raise DDFLoadError(self.netpath)

        except yaml.scanner.ScannerError, err:
            log.error("Error in YAML config file " % err)
コード例 #5
0
ファイル: provisioning.py プロジェクト: l0r3zz/vDeploy
    def __init__(self, args):

        log.info("Starting config file processing")

        # Scan for presence of config directory
        config_dir = "./"
        for dpath in CONFIG_DIR_DEFAULTS:
            if os.path.exists(dpath):
                config_dir = dpath
                break
        self.ddfdict = {}
        # Attempt to load all of the data structure temple definitions
        try:
            self.hvpath = config_dir + HVDEF_TEMPLATE
            if os.path.exists(self.hvpath):
                self.hvtemplate = yaml.load(file(self.hvpath))
                self.ddfdict["hdf"] = self.hvpath
                if not self.hvtemplate:
                    mylog.printlog(log, "%s is empty" % self.hvpath, "INFO")
            else:
                raise DDFLoadError(self.hvpath)

            self.vmpath = config_dir + VMDEF_TEMPLATE
            if os.path.exists(self.vmpath):
                self.vmtemplate = yaml.load(file(self.vmpath))
                self.ddfdict["vdf"] = self.vmpath
                if not self.vmtemplate:
                    mylog.printlog(log, "%s is empty" % self.vmpath, "INFO")
            else:
                raise DDFLoadError(self.vmpath)

            self.netpath = config_dir + NETDEF_TEMPLATE
            if os.path.exists(self.netpath):
                self.nettemplate = yaml.load(file(self.netpath))
                self.ddfdict["ndf"] = self.netpath
                if not self.nettemplate:
                    mylog.printlog(log, "%s is empty" % self.netpath, "INFO")
            else:
                raise DDFLoadError(self.netpath)

        except yaml.scanner.ScannerError, err:
            log.error("Error in YAML config file " % err)
コード例 #6
0
#!/bin/env python
#-*- coding: utf-8 -*-

import mylog

mylog.printlog("/var/log/messages", "fail")
コード例 #7
0
#!/bin/env python
#-*- coding: utf-8 -*-

import mylog
import os

logfile = "/var/log/messages"
file_length = os.path.getsize(logfile)

mylog.printlog("/var/log/messages", "fail", int(file_length / 2), 3, 5)
コード例 #8
0
#!/usr/bin/python
#find fail from the log and display before and after lines, it works with mylog.py
import mylog
mylog.printlog("/var/log/system.log", "fail", 3, 5)
コード例 #9
0
ファイル: exec_mylog.py プロジェクト: zeroam/TIL
#!/bin/env python
import os
import mylog

logfile = "/var/log/syslog"
file_length = os.path.getsize(logfile)
# 메시지 로그의 중간부터 추적
mylog.printlog(logfile, "fail", int(file_length / 2), 3, 5)