コード例 #1
0
def process_task(user):
    """
    This worker is responsible for creating entries on the platform
    :param user: a user object
    :param entry: contains the information about the entry which should be created on the platform
    :param status: contains for which task is the entry
    """
    task = Task(user)
    task.create()

    report = Report(user, COSMOS_TRACKER)
    report.send()
コード例 #2
0
def new_process_command(command, name="Unknown"):
    """Runs a system command and saves it in Tasks
    
    Args:
        command (list/str): command to run
        name (str, optional): Name of the process. Defaults to "Unknown".
    """
    if not (type(command) == type([])):
        command = command.split(" ")
    q = multiprocessing.Queue()
    th = CustomProcess(name=name, target=_popen_run, args=(q, command))
    th.start()
    #th.join()
    pid = q.get()
    Task().get_instance().add_task(th, pid)
    print_info("Task running in background... use 'tasks list' to check")
コード例 #3
0
ファイル: launchService.py プロジェクト: wanggh1021/KITT
    def run(self):
        hci = self.args["iface"]
        name = "DirtytoothSpeaker"
        if self.args['name']:
            name = self.args['name']
        if Task.get_instance().exist_task("dirtyagent"):
            print_info("A dirtyagent is running... Kill it first")
            return
        tool = "hciconfig"
        options =  [f"{hci} name {name}", f"{hci} reset", f"{hci} class {self.args['class']}",f"{hci} noauth", f"{hci} piscan"]

        for op in options:
            system(tool + " " +  op)
        new_process_function(run_agent, name="dirtyagent")
        #new_process_command("./utils/dirtytooth/dirtyagent", name="dirtyagent")
        
コード例 #4
0
def new_process_function(func, args=None, name="Unknown", seconds_to_wait=0):
    """Runs a python function and saves it in Task
    
    Args:
        func (func): Function type
        args (list, optional): List of args of the funcion. Defaults to None.
        name (str, optional): Name of the process. Defaults to "Unknown".
        seconds_to_wait (int, optional): Seconds to wait to execute the function. Defaults to 0.
    """
    try:
        if args:
            th = CustomProcess(name=name, target=func, args=(args, ))
        else:
            th = CustomProcess(name=name, target=func)
        th.start()
        Task().get_instance().add_task(th, th.pid, seconds_to_wait)
        print_info("Task running in background... use 'tasks list' to check")
    except:
        pass
コード例 #5
0
ファイル: test_utils.py プロジェクト: wanggh1021/KITT
def test_tasks():
    task = Task()
    assert task.count == 1
    assert len(task.get_tasks()) == 0
    new_process_function(to_test_th)
    assert task.count == 2
    assert len(task.get_tasks()) == 1
    task.kill_task(1)
    assert task.count == 2
    assert len(task.get_tasks()) == 0
    new_process_function(to_test_th)
    task.kill_task(1)
    assert task.count == 3
    assert len(task.get_tasks()) == 1
    task.kill_task(2)
    assert len(task.get_tasks()) == 0
コード例 #6
0
ファイル: command_parser.py プロジェクト: wanggh1021/KITT
 def _exit(self, param=None):
     print_info("Killing tasks... ")
     Task().get_instance().kill_all_tasks()
     print_info("Bye...")
     _exit(0)
コード例 #7
0
ファイル: command_parser.py プロジェクト: wanggh1021/KITT
 def _task(self, params):
     if "list" in params:
         Task().get_instance().show_tasks()
     elif "kill" in params and len(params) >= 2:
         Task().get_instance().kill_task(params[1])
コード例 #8
0
ファイル: dirtytooth.py プロジェクト: wanggh1021/KITT
def can_run_dirtytooth():
    return Task.get_instance().exist_task("dirtyagent")