Exemplo n.º 1
0
    def init_compare(self, new_my_dir, target_dir):
        target_dir_tree = GlobalVariable.dir_tree[target_dir]
        #把自己和其它dir进行比较
        for file in new_my_dir:
            #目标文件夹里没有此文件,新增
            if not target_dir_tree.has_key(file):
                GlobalVariable.task_queue.put(
                    Task(self.dir + file, target_dir + file, "add"))
                continue

            #确实被更新过,并且md5不相同的
            if new_my_dir[file]['mtime'] > target_dir_tree[file]['mtime']:
                if md5(self.dir + file) != md5(target_dir + file):
                    GlobalVariable.task_queue.put(
                        Task(self.dir + file, target_dir + file, "modify"))
                    continue
Exemplo n.º 2
0
def get_all_tasks(message):
    '''обновим в бд все server_task_id согласно полученному сообщению'''
    print('get all tasks->', message)
    # da = data['db'].get_all_tasks()
    # notification(da)
    put_message(message)
    if message['body']['code'] == 200:
        for server_task_id, task_ in message['body']['message'].items():
            task_id = data['db'].get_task_id_by_name(task_.get('name'))

            if task_id:
                data['db'].set_task_id(task_id, server_task_id)
                data['db'].change_date_reminder(task_id, task_.get('date_reminder'))
                data['db'].change_time_reminder(task_id, task_.get('time_reminder'))
            else:
                creator = data['username']
                task = Task(creator=creator, viewer=creator, name=task_.get('name'))
                task.id = int(server_task_id)
                task.description = task_.get('description')
                task.date_reminder = task_.get('date_reminder')
                task.time_reminder = task_.get('time_reminder')
                task = task.task_dict
                print('task->', task)
                data['db'].add_task(task)

    da = data['db'].get_all_tasks()
    print('da', da)
    notification(da)
    release_queue()
Exemplo n.º 3
0
    def appendTask(self,
                   analyst,
                   title: str,
                   description: str,
                   priority: Priority,
                   progress: Progress,
                   dueDate: datetime,
                   associationToTask: list,
                   analystAssignment: list,
                   collaboratorAssignment: list,
                   archiveStatus: bool,
                   associationToSystem,
                   attachment: list = [],
                   parentId=-1,
                   id=-1):

        new_task = Task(title=title,
                        description=description,
                        priority=priority,
                        progress=progress,
                        dueDate=dueDate,
                        associationToTask=associationToTask,
                        analystAssignment=analystAssignment,
                        collaboratorAssignment=collaboratorAssignment,
                        archiveStatus=archiveStatus,
                        attachment=attachment,
                        parentId=parentId,
                        associationToSystem=associationToSystem,
                        id=id)

        new_task.setId(self.__updateTask(analyst=analyst, task=new_task))
        self.__task.append(new_task)
        return
Exemplo n.º 4
0
def create_task(message):
    if message['body']['code'] == 201:
        creator = data['username']
        server_task_id = message['body'].get('id')
        task_name = data['create_task']['body'].get('name')
        task_description = data['create_task']['body'].get('description')
        task_date_reminder = data['create_task']['body'].get('date_reminder')
        task_time_reminder = data['create_task']['body'].get('time_reminder')
        data.pop('create_task')

        task = Task(creator=creator, viewer=creator, name=task_name)
        task.date_reminder = task_date_reminder
        task.time_reminder = task_time_reminder
        task.description = task_description
        task.id = int(server_task_id)
        task = task.task_dict
        print('task->', task)

        data['db'].add_task(task)

    else:
        print(message['body']['code'], message['body']['message'])

    put_message(message)
    release_queue()
Exemplo n.º 5
0
	def run(self):
		while(True):
			self._lock.acquire()	
			rand = randrange(1,20,1) 
			print("running bluetooth thread ",rand)
			self._queue.put(Task("random task",rand))
			self._lock.release()
			time.sleep(self._wait)
Exemplo n.º 6
0
def load(name):
	tasks = []
	with open("tasks.txt") as file:
		for task in file:
			words = task.split()
			if str(words).find("#") != -1: 
				break
			sp = words[0]
			name = ' '.join(words[1:])
			tasks.append(Task(sp, name=name))
	return tasks
Exemplo n.º 7
0
def task_create():
    """Add new task to a list."""
    task = Task(None)

    if request.method == "POST":
        content = request.get_json(silent=True)
        if not content:
            abort(400)
        task.from_dict(content)

    dynamo.tasks_master.put_item(data=task.as_dict())
    return "Task ID: %s" % task.get_id()
Exemplo n.º 8
0
 def convertDocument(document):
     return Task(title=document["title"],
                 description=document["description"],
                 priority= document["priority"],
                 progress=Progress.getMember(document["progress"]),
                 dueDate=document["dueDate"],
                 attachment=document["attachment"],
                 associationToTask=document["association"],
                 analystAssignment=document["analyst_Assignment"],
                 collaboratorAssignment=document["collaborator_Assignment"],
                 archiveStatus=document["archive_status"],
                 associationToSystem=document["system_Association"],
                 parentId= document["parent_task"],
                 id=document["_id"])
Exemplo n.º 9
0
 def submit(self, task_name: str, task_cfg: dict):
     """提交一个Task
     Args:
         task_name: task的名字,需要保证不重复,其会作为task的唯一标识符,建议传入视频或摄像头名称
         task_cfg: task的数据字典
     Returns:
         返回是否返回值
     """
     # 如果超过了最多的提交数量限制
     if len(self.tasks) >= TaskConfig.MAX_TASK_NUM:
         raise RuntimeError("超过了最多的提交数量限制".format(task_name))
     if self.is_exist(task_name):
         raise RuntimeError("请勿重复提交task_name为{}的Task任务".format(task_name))
     task = Task(task_cfg)
     task.build(timeout=20)
     self.tasks[task_name] = task
Exemplo n.º 10
0
def task_search(owner):
    """Return list of Tasks wit specified owner."""
    data = {"items": []}
    length = 0

    data["table_name"] = "tasks_master"
    results = dynamo.tasks_master.query(owner__eq=owner,
                                        index='secondKeyIndex')
    for r in results:
        data["items"].append(dict(r.items()))

        t = Task("")
        t.from_dict(dict(r.items()))
        length += 1
    data["items_length"] = length

    if length < 1:
        abort(404)

    return json.dumps(data, indent=4, cls=DecimalEncoder)
Exemplo n.º 11
0
def get_task_by_id(message):
    '''обновим в бд все server_task_id согласно полученному сообщению'''
    print('get task->', message)
    if message['body']['code'] == 200:
        creator = data['username']
        name = message['body'].get('task name')
        description = message['body'].get('description')
        date_reminder = message['body'].get('date_reminder')
        time_reminder = message['body'].get('time_reminder')
        task = Task(name=name, creator=creator, viewer=creator)
        task.description = description
        task.date_reminder = date_reminder
        task.time_reminder = time_reminder
        task = task.task_dict

        # data['db'].add_task(task)
    else:
        print(message['body']['code'], message['body']['message'])

    put_message(message)
    release_queue()
Exemplo n.º 12
0
 def create_task(self, log_path, src_path=''):
     task = Task(log_path, src_path)
     # 添加到ui的任务处理队列
     self.ui.AddTaskToProcessPanel(task)
     # 添加到TaskManager中处理
     self.task_manager.add_task(task)
Exemplo n.º 13
0
 def OnStartButton(self, evt):
     #self.test.addProcess(self.writer)
     task = Task(str(uuid.uuid4()), Task.__STATE_NEW__, "", "")
     print "add task = ", task.name
     self.tm.add_task(task)
Exemplo n.º 14
0
import time
import traceback

import pyautogui

import action
from task.down import Down
from task.multi import Multi
from task.task import Task
from task.tiaozhan import Tiaozhan
from task.zhunbei import Zhunbei

pyautogui.PAUSE = 0.1

task = Task(True)
tasks = []
start_time = time.time()

print('程序启动,现在时间', time.ctime())


def log(f):
    def wrap(*agrs, **kwagrs):
        try:
            ans = f(*agrs, **kwagrs)
            return ans
        except:
            traceback.print_exc()
            time.sleep(60)

    return wrap
Exemplo n.º 15
0
from task.task import Task

a_range = [
    5.67319, 5.67485, 5.67635, 5.67821, 5.67950, 5.68118, 5.68267, 5.68451,
    5.68558, 5.68744, 5.68898, 5.69045, 5.69224, 5.69367, 5.69530, 5.69699,
    5.69825, 5.69980, 5.70158, 5.70323, 5.70445, 5.70575, 5.70765, 5.70923,
    5.71076, 5.71217, 5.71374, 5.71531, 5.71670
]
c_a_range = [
    1.09067, 1.09084, 1.09110, 1.09116, 1.09154, 1.09169, 1.09196, 1.09202,
    1.09253, 1.09257, 1.09281, 1.09307, 1.09316, 1.09345, 1.09363, 1.09378,
    1.09416, 1.09438, 1.09447, 1.09463, 1.09504, 1.09540, 1.09542, 1.09561,
    1.09584, 1.09613, 1.09634, 1.09653, 1.09684
]

task = Task('config.ini')
task.set('multiple phonon')
indexRange = range(10, 22, 2)
print indexRange
for i in indexRange:
    varnameValue(task.pwscfInput, 'celldm(1)', a_range[i])
    varnameValue(task.pwscfInput, 'celldm(2)', a_range[i])
    varnameValue(task.pwscfInput, 'celldm(3)', c_a_range[i])
    geometry = [
        'Al       0.000000000   0.0000000000000000   0.000000000',
        'B        0.500000000   0.2886751345948129   ' +
        str(c_a_range[i] / 2.),
        'B        0.000000000   0.5773502691896257   ' + str(c_a_range[i] / 2.)
    ]
    atomic_positions(task.pwscfInput, geometry)
    task.getLauncher()
Exemplo n.º 16
0
#!/usr/bin/env python3

from task.task import Task
from utils.parser import args

if __name__ == "__main__":
    t = Task()

    if args.add:
        t.add(args.add, args.priority[0] if args.priority else "2")

    elif args.note:
        t.note(args.note)

    elif args.check:
        t.check(args.check)

    elif args.begin:
        t.begin(args.begin)

    elif args.remove:
        t.remove(args.remove)

    elif args.clear:
        t.clear()

    elif args.sort:
        t.sort_ids()

    else:
        t.show()
Exemplo n.º 17
0

def read_info_from_task(mqs):
    try:
        while True:
            for mq in mqs:
                img_info = mq.get(timeout=5)
    except Empty:
        print('主进程结束')


if __name__ == '__main__':
    # Linux平台启动
    if platform.system() == 'Linux':
        mp.set_start_method('spawn', force=True)
    # 建模任务
    args = parse_args()
    if not osp.exists(args.i):
        raise AttributeError('输入文件不存在')
    print('处理视频为{},保存环境模型到{},是否开启方向矫正:{}'.format(args.i, args.o, args.revise))
    TaskCfg['head'][0]['filename'] = args.i
    TaskCfg['backbones'][0][1]['modelPath'] = args.o
    TaskCfg['backbones'][0][1]['revise'] = args.revise
    TaskCfg['backbones'][0][1]['dataNum'] = args.n
    task = Task(TaskCfg)
    mqs = task.build()
    task.start()
    readt = Thread(target=read_info_from_task, args=(mqs, ))
    readt.start()
    readt.join()
Exemplo n.º 18
0
Arquivo: ddpg.py Projeto: s-bl/cwyc
    def __init__(self,
                 env_spec,
                 task_spec,
                 buffer_size,
                 network_params,
                 normalizer_params,
                 polyak,
                 batch_size,
                 Q_lr,
                 pi_lr,
                 max_u,
                 action_l2,
                 clip_obs,
                 scope,
                 random_eps,
                 noise_eps,
                 train_steps,
                 relative_goals,
                 clip_pos_returns,
                 clip_return,
                 replay_strategy,
                 replay_k,
                 noise_type,
                 share_experience,
                 noise_adaptation,
                 reuse=False):
        """Implementation of DDPG that is used in combination with Hindsight Experience Replay (HER).
            Added functionality to use demonstrations for training to Overcome exploration problem.

        Args:
            input_dims (dict of ints): dimensions for the observation (o), the goal (g), and the
                actions (u)
            buffer_size (int): number of transitions that are stored in the replay buffer
            hidden (int): number of units in the hidden layers
            layers (int): number of hidden layers
            network_class (str): the network class that should be used (e.g. 'baselines.her.ActorCritic')
            polyak (float): coefficient for Polyak-averaging of the target network
            batch_size (int): batch size for training
            Q_lr (float): learning rate for the Q (critic) network
            pi_lr (float): learning rate for the pi (actor) network
            norm_eps (float): a small value used in the normalizer to avoid numerical instabilities
            norm_clip (float): normalized inputs are clipped to be in [-norm_clip, norm_clip]
            max_u (float): maximum action magnitude, i.e. actions are in [-max_u, max_u]
            action_l2 (float): coefficient for L2 penalty on the actions
            clip_obs (float): clip observations before normalization to be in [-clip_obs, clip_obs]
            scope (str): the scope used for the TensorFlow graph
            T (int): the time horizon for rollouts
            rollout_batch_size (int): number of parallel rollouts per DDPG agent
            subtract_goals (function): function that subtracts goals from each other
            relative_goals (boolean): whether or not relative goals should be fed into the network
            clip_pos_returns (boolean): whether or not positive returns should be clipped
            clip_return (float): clip returns to be in [-clip_return, clip_return]
            sample_transitions (function) function that samples from the replay buffer
            gamma (float): gamma used for Q learning updates
            reuse (boolean): whether or not the networks should be reused
            bc_loss: whether or not the behavior cloning loss should be used as an auxilliary loss
            q_filter: whether or not a filter on the q value update should be used when training with demonstartions
            num_demo: Number of episodes in to be used in the demonstration buffer
            demo_batch_size: number of samples to be used from the demonstrations buffer, per mpi thread
            prm_loss_weight: Weight corresponding to the primary loss
            aux_loss_weight: Weight corresponding to the auxilliary loss also called the cloning loss
        """
        super().__init__(scope)
        self.replay_k = replay_k
        self.replay_strategy = replay_strategy
        self.clip_pos_returns = clip_pos_returns
        self.relative_goals = relative_goals
        self.train_steps = train_steps
        self.noise_eps = noise_eps
        self.random_eps = random_eps
        self.clip_obs = clip_obs
        self.action_l2 = action_l2
        self.max_u = max_u
        self.pi_lr = pi_lr
        self.Q_lr = Q_lr
        self.batch_size = batch_size
        self.normalizer_params = normalizer_params
        self.polyak = polyak
        self.buffer_size = buffer_size
        self._env_spec = env_spec
        self._T = self._env_spec['T']
        self._task_spec = task_spec
        self.network_params = network_params
        self._share_experience = share_experience
        self._noise_adaptation = noise_adaptation

        self._task_spec = deepcopy(task_spec)
        self._task_spec['buffer_size'] = 0
        self._task = Task(**self._task_spec)

        self._gamma = 1. - 1. / self._T
        self.clip_return = (1. / (1. - self._gamma)) if clip_return else np.inf

        if self.clip_return is None:
            self.clip_return = np.inf

        self.create_actor_critic = import_function(network_params['net_type'])

        self.input_dims = dict(
            o=self._env_spec['o_dim'],
            a=self._env_spec['a_dim'],
            g=self._task_spec['g_dim'],
        )

        input_shapes = dims_to_shapes(self.input_dims)

        self.dimo = self._env_spec['o_dim']
        self.dimg = self._task_spec['g_dim']
        self.dima = self._env_spec['a_dim']

        # Prepare staging area for feeding data to the model.
        stage_shapes = OrderedDict()
        for key in sorted(self.input_dims.keys()):
            if key.startswith('info_'):
                continue
            stage_shapes[key] = (None, *input_shapes[key])
        for key in ['o', 'g']:
            stage_shapes[key + '_next'] = stage_shapes[key]
        stage_shapes['r'] = (None, )
        self.stage_shapes = stage_shapes

        self._action_noise, self._parameter_noise = get_noise_from_string(
            self._env_spec, noise_type)

        # Create network.
        with tf.variable_scope(self._scope):
            self.staging_tf = StagingArea(
                dtypes=[tf.float32 for _ in self.stage_shapes.keys()],
                shapes=list(self.stage_shapes.values()))
            self.buffer_ph_tf = [
                tf.placeholder(tf.float32, shape=shape)
                for shape in self.stage_shapes.values()
            ]
            self.stage_op = self.staging_tf.put(self.buffer_ph_tf)

            self._create_network(reuse=reuse)

        buffer_shapes = dict()
        buffer_shapes['o'] = (self.dimo, )
        buffer_shapes['o_next'] = buffer_shapes['o']
        buffer_shapes['g'] = (self.dimg, )
        buffer_shapes['ag'] = (self.dimg, )
        buffer_shapes['ag_next'] = (self.dimg, )
        buffer_shapes['a'] = (self.dima, )

        self.sample_transitions = make_sample_her_transitions(
            self.replay_strategy, self.replay_k,
            self._task.reward_done_success)

        self._buffer = ReplayBuffer(buffer_shapes, self.buffer_size, self._T,
                                    self.sample_transitions)
Exemplo n.º 19
0
import time
import traceback

import pyautogui

import action
from task.down import Down
from task.task import Task
from task.tiaozhan import Tiaozhan
from task.zhunbei import Zhunbei

pyautogui.PAUSE = 0.1

task = Task()
tasks = []
start_time = time.time()

print('程序启动,现在时间', time.ctime())


def log(f):
    def wrap(*agrs, **kwagrs):
        try:
            ans = f(*agrs, **kwagrs)
            return ans
        except:
            traceback.print_exc()
            time.sleep(60)

    return wrap
Exemplo n.º 20
0
    ).pid
    if progress >= 1:
        print "Task Done"


if __name__ == "__main__":

    #path = "/home/qinsw/pengtian/tmp/cmcc_monkey/asrlog-0037(1122)/asrlog-2017-11-21-17-06-29/1/android"
    #path = "/home/pt/Downloads/2018-03-07_10_30_46/2018-03-07_10_30_46/1d469105" #99
    # path = "/home/pt/Downloads/2018-03-07_10_30_46/2018-03-07_10_30_46/1d469132" #100
    #path = "/home/pt/Downloads/2018-03-07_10_30_46/2018-03-07_10_30_46/c351cc5f"
    # path = "/home/pt/Downloads/2018-03-07_10_30_46/2018-03-07_10_30_46/1d469018" #error
    # path = "/home/pt/Downloads/2018-03-07_10_30_46/2018-03-07_10_30_46/ptt2"
    #path = "/home/pt/Downloads/android/crash-17-17-13.log"
    #list = tool.getParseableFileList(path)

    #path = "/home/pt/Downloads/2018-03-07_10_30_46/2018-03-07_10_30_46/./1d469105/com.google.android.apps.wallpaper2018-03-11_19_10_15ANR.log"
    #path = "/home/pt/Downloads/2018-03-07_10_30_46/2018-03-07_10_30_46/ptt1/com.android.chrome2018-03-08_18_36_47CRASH.log"

    path = "/home/pt/Downloads/2018-03-07_10_30_46/2018-03-07_10_30_46"
    #print list

    task = Task(path, '')
    print "load = %d " % task.getLoad()
    pm = ParserManager(task)
    #pm.setProgressCallback(progress_callback)
    pm.execute()

    import time
    time.sleep(400)