Exemplo n.º 1
0
    def run(self):
        if not self.__check():
            Log.e("Input file does not exists")
            self.__showErrorDialog("File path does not exists")
            return

        self.__runner = Runner(self.__outputFile)
        try:
            Log.i("Started recording")
            self.__runner.runCommand()
        except ChildProcessError:
            self.__showErrorDialog("Error running FFmpeg")
Exemplo n.º 2
0
    def __actionArmEmpty(self):
        """
        Action taken when arm is empty

        References
        ----------

        armEmpty() -> putDown(?Z) | stack(?X, ?Y)

        """
        Log.d(f"Arm is empty :: {self.__planningStack}")
        exit(1)
Exemplo n.º 3
0
def main():

    str_today = getDate(0)
    str_sevenday = getDate(7)
    log = Log.make_logger()

    start_time = time.time()
    with ThreadPoolExecutor() as executor:
        all_task = [executor.submit(
            run.run,
            (ip),
        ) for ip in ipInfo()]


#----------------------------------------------------------------------------
#    old_date='20201009'
#    new_date='20201010'
#    difftable.dodiff(abs_path,old_date,new_date)
#----------------------------------------------------------------------------
#    dbpath = os.path.join(abs_path,sqlite3path)
#    file_path = os.path.join(abs_path,"dbtables")
#    goToPast(dbpath,file_path,old_date,new_date)
#----------------------------------------------------------------------------

    cost_time = time.time() - start_time
    log.info('>>>>> cost : {:.2f} s <<<<< '.format(cost_time))
Exemplo n.º 4
0
 def __init__(self):
     super(Napoli, self).__init__()
     if getattr(self, '__init', False):
         # do initialization here
         self.config = Config.get_instance()
         os.environ['APPPATH'] = self.config.application
         sys.path.append(os.path.dirname(os.environ['APPPATH']))
         self.log = Log()
         self.plugins = Plugins()
         self._load_plugins()
         self.routes = Routes()
Exemplo n.º 5
0
    def runCommand(self):
        """
        Running the command line with subprocess module, using the Log class to print some info
        and errors
        """
        self.__run = subprocess.Popen(args=self.buildCommand(),
                                      stdout=subprocess.PIPE,
                                      stderr=subprocess.STDOUT,
                                      universal_newlines=True,
                                      preexec_fn=os.setsid)

        if not self.__processKilled:
            for _ in iter(self.__run.stdout.readlines, ""):
                pass

        self.__run.stdout.close()

        if self.__run.wait():
            Log.e("Error occurred while running the PyRecorder Command line.")
            raise ChildProcessError("It's not working")

        return
Exemplo n.º 6
0
class Napoli(Singleton):
    def __init__(self):
        super(Napoli, self).__init__()
        if getattr(self, '__init', False):
            # do initialization here
            self.config = Config.get_instance()
            os.environ['APPPATH'] = self.config.application
            sys.path.append(os.path.dirname(os.environ['APPPATH']))
            self.log = Log()
            self.plugins = Plugins()
            self._load_plugins()
            self.routes = Routes()

    def _load_plugins(self):
        try:
            for name in self.config.plugins['default']:
                self.plugins.install(name)
        except KeyError as ex:
            self.log.debug(ex)
        except Exception as ex:
            self.log.exception(ex)


    def wsgi(self, environ, start_response):
        """
        All per request initialization goes here
        """
        # initialize router
        router = Router(self.routes)
        router.route(environ['PATH_INFO'])
        # dispatch
        dispatcher = Dispatcher(Request(environ), router)
        res = dispatcher.dispatch()
        return res

    def __call__(self, environ, start_response):
        res = self.wsgi(environ, start_response)
        return res(environ, start_response)
Exemplo n.º 7
0
def main():

    log = Log.make_logger()
    start_time = time.time()
    # ods
    with ThreadPoolExecutor() as executor:
        all_task = [
            executor.submit(
                run_yzAyc,
                (ip),
            ) for ip in ipInfo_compare(2)
        ]

    cost_time = time.time() - start_time
    log.info('>>>>> cost : {:.2f} s <<<<< '.format(cost_time))
Exemplo n.º 8
0
def getTopData(val, host, app_id, app_name, env):
    log = Log.make_logger()
    pattern = re.compile("x'.*'")
    stmt_text = ""
    for line in val.split("\n"):
        if pattern.search(line):
            if len(stmt_text) > 0:
                stmt_text = re.sub(r'[\x00-\x1f]|  |\'|\"', "", stmt_text)
                getfile.saveSql_db2(host, app_id, app_name, env, executable_id,
                                    stmt_text, num_execution, avg_exec_time,
                                    stmt_exec_time)
                stmt_text = ''
            executable_id = line.split()[0]
            insert_timestamp = line.split()[1]
            section_type = line.split()[2]
            num_execution = line.split()[3]
            stmt_exec_time = line.split()[4]
            avg_exec_time = line.split()[5]
            stmt_text = ' '.join(line.split()[6:])
        elif len(stmt_text) > 0:
            stmt_text = ''.join(stmt_text + line + '\n')
Exemplo n.º 9
0
    def getPlan(self, startState: str, goalState: str):
        """
        Run the Goal Stack Planner and creates the final plan to achieve the Goal State

        Parameters
        ----------
        startState : str
            starting state
        goalState : str
            goal state to achieve

        Returns
        -------
        list
            list of actions to be taken to achieve the goal state
        """
        self.__startState = startState.split(self.__sep)
        self.__goalState = goalState.split(self.__sep)
        self.__currentStack = self.__startState.copy()

        # creating the plan stack
        for predicate in self.__goalState:
            self.__planningStack.append(predicate)

        # running for the stack empty
        while len(self.__planningStack) > 0:
            if self.__verbose:
                Log.d(f"Planning Stack :: {self.__planningStack}")
                Log.d(f"Current Stack :: {self.__currentStack}")

            top = self.__planningStack.pop()
            temp = top.split()

            # if it is a predicate in current stack pop it
            if temp[0] in self.__predicates:
                if top in self.__currentStack:
                    continue

                else:
                    # if it is a predicate
                    if temp[0] == Predicate.ON:
                        self.__actionOn(temp[1], temp[2])

                    elif temp[0] == Predicate.ON_TABLE:
                        self.__actionOnTable(temp[1])

                    elif temp[0] == Predicate.CLEAR:
                        self.__actionClear(temp[1])

                    elif temp[0] == Predicate.HOLDING:
                        self.__actionHolding(temp[1])

                    elif temp[0] == Predicate.ARM_EMPTY:
                        self.__actionArmEmpty()

            if temp[0] in self.__actions:
                # if it is an action
                if temp[0] == Action.STACK:
                    self.__effectStack(temp[1], temp[2])

                elif temp[0] == Action.UNSTACK:
                    self.__effectUnStack(temp[1], temp[2])

                elif temp[0] == Action.PICKUP:
                    self.__effectPickUp(temp[1])

                elif temp[0] == Action.PUTDOWN:
                    self.__effectPutDown(temp[1])

                # add processed action
                self.__plan.append(top)

        if self.__verbose:
            Log.d(f"Final stack :: {self.__currentStack}")

        return self.__plan
Exemplo n.º 10
0
#!/usr/bin/python
#coding:utf-8
import sys
sys.path.append("..")
from etc.setting_mysql import *
from lib.logger import Log
log = Log.make_logger()

from lib.DBTool import mysql


def ipInfo():
    sql = 'select a.dbs,a.ipaddr,b.sysuser,b.syspassword,a.app_id,c.app_name,a.env,d.dbuser,d.dbpassword,d.port,d.dbname,d.tabowner,c.importance_table from hosts a join hosts_passwd b on a.dbs !=0 and a.host_status=1 and a.hostid=b.hostid and b.isinstance=1 join app c on a.app_id = c.app_id join database_passwd d on a.hostid=d.hostid ;'
    #sql= 'select a.dbs,a.ipaddr,b.sysuser,b.syspassword,a.app_id,c.app_name,a.env,d.dbuser,d.dbpassword,d.port,d.dbname,c.importance_table from hosts a join hosts_passwd b on a.dbs !=0 and a.host_status=1 and a.hostid=b.hostid and b.isinstance=1 join app c on a.app_id = c.app_id join database_passwd d on a.hostid=d.hostid and a.ipaddr="203.3.238.3" and d.dbname="hrmsdb";'
    apmdb = mysql(apm_host, apm_port, amp_database, apm_user, apm_passwd)
    with apmdb:
        rows = apmdb.exec_sql(sql)
        #print rows
        for dbs, ipaddr, sysuser, syspassword, app_id, app_name, env, dbuser, dbpassword, db_port, db_dbname, tab_owner, importance_table in rows:
            yield dbs, ipaddr.strip(), sysuser.strip(), syspassword.strip(
            ), app_id, app_name.strip(), env, dbuser.strip(), dbpassword.strip(
            ), int(db_port), db_dbname.strip(), str(
                tab_owner), importance_table


def ipInfo_compare(compare_type):
    #sql = 'select a.ip,a.dbuser,a.dbpwd,a.port,a.dbname,b.schema,b.compare_file,c.app_name from ods_ip a join ods_compare b on a.compare_id = b.compare_id join app c on b.app_id = c.app_id'
    sql = 'select a.ip,a.dbuser,a.dbpwd,a.port,a.dbname,b.schema,c.app_name,d.ipaddr,d.dbs,f.dbuser,f.dbpassword,f.port,f.dbname,f.tabowner from compare_ip a join compare_config b on a.compare_id = b.compare_id join app c on b.app_id = c.app_id join hosts d on d.hostid = b.hostid join database_passwd f on b.hostid = f.hostid and  b.compare_type = {}'.format(
        int(compare_type))
    apmdb = mysql(apm_host, apm_port, amp_database, apm_user, apm_passwd)
    with apmdb:
Exemplo n.º 11
0
from lib.logger import Log

Log.setPrint(True)
Log.d("Ok this function is working")
Log.i("The video format suggested is .mp4")
Log.e("Error parsing the video format")
Log.w(f"Using mpeg4sc to parse the video : {10 ** 10}xdRG")
Exemplo n.º 12
0
from lib.logger import Log
from lib.planner import Planner

startState = input("Enter the start state :: ")
goalState = input("Enter the goal state :: ")
print()

planner = Planner(verbose=True)
plan = planner.getPlan(startState=startState, goalState=goalState)
Log.e(f"Final plane derived ::")
for p in plan:
    Log.i(p)
Exemplo n.º 13
0
            raise ImportWarning(name + ' is not found.')
        bottle.install(cls())


if __name__ == '__main__':
    args = parse_args()

    # initialize Config
    config = Config(args.config)

    # the log file
    logfile = config.logger['filepath'].format(args.port, date.today())
    # the pid fle
    pidfile = config.pidfile.format(args.port)
    # initialize logger
    log = Log(logfile)

    # make directory to put pid file
    piddir = os.path.dirname(pidfile)
    if not os.path.isdir(piddir):
        os.makedirs(piddir)

    # the app
    app = Dispatcher(StripPath(SessionWsgi(bottle.app())), config)
    decanter = Decanter(app,
                        hostname=args.hostname,
                        port=args.port,
                        pidfile=pidfile,
                        development=args.command == 'runserver')

    # execute command
Exemplo n.º 14
0
 def terminateCommand(self):
     if self.__run is not None:
         os.killpg(os.getpgid(self.__run.pid), signal.SIGTERM)
         self.__processKilled = True
     Log.i("Recording saved successfully")