Exemplo n.º 1
0
def run(args):
    # 絶対パスに変換
    args.srcdir = os.path.abspath(args.srcdir)

    # 実行時間から、タスク名を決める
    if len(args.name) == 0:
        date = datetime.now().strftime("%Y%m%d_%H%M%S")
        args.name = date
        cnt = 0
        while os.path.exists(os.path.join(config.TMP_PATH, args.name)):
            args.name = '{}_{}'.format(date, cnt)
            cnt += 1
    elif os.path.exists(os.path.join(config.TMP_PATH, args.name)):
        print('[Error] すでに存在するタスク名です {}'.format(args.name))
        exit(1)

    print('--- Args ---')
    print('srcdir : {}'.format(args.srcdir))
    print('run    : {}'.format(args.run))
    print('name   : {}'.format(args.name))
    print('')

    # 存在確認
    if (os.path.isdir(args.srcdir) == False):
        print('[Error] ディレクトリが存在しません: {}'.format(args.srcdir))
        exit(1)
    if (os.path.isfile(args.run) == False):
        print('[Error] ファイルが存在しません: {}'.format(args.run))
        exit(1)

    # 実行待ちのため、一時的なディレクトリにコピー
    tmpPath = os.path.join(config.TMP_PATH, args.name)
    tmpSrcPath = os.path.join(tmpPath, 'src')
    shutil.copytree(args.srcdir,
                    tmpSrcPath,
                    ignore=shutil.ignore_patterns('.*'))  # ディレクトリごとコピー

    # orderfile.jsonの作成
    orderfilePath = os.path.join(tmpPath, config.ORDERFILE_NAME)
    f = open(orderfilePath, "w")
    json.dump(args.__dict__, f)
    f.close()

    # Taskの登録
    data = {
        'request': 'query',
        'data': args.__dict__,
    }
    client.query(data)

    # 完了メッセージ
    print('Success. Order received.')
Exemplo n.º 2
0
 def status(self, files, match, list_ignored, list_clean,
            list_unknown=True):
     try:
         if not list_ignored and not self.inotifyserver:
             result = client.query(ui, repo, files, match, False,
                                   list_clean, list_unknown)
             if result is not None:
                 return result
     except socket.error, err:
         if err[0] == errno.ECONNREFUSED:
             ui.warn(_('(found dead inotify server socket; '
                            'removing it)\n'))
             os.unlink(repo.join('inotify.sock'))
         elif err[0] != errno.ENOENT:
             raise
         if ui.configbool('inotify', 'autostart'):
             query = None
             ui.debug(_('(starting inotify server)\n'))
             try:
                 server.start(ui, repo)
                 query = client.query
             except server.AlreadyStartedException, inst:
                 # another process may have started its own
                 # inotify server while this one was starting.
                 ui.debug(str(inst))
                 query = client.query
             except Exception, inst:
                 ui.warn(_('could not start inotify server: '
                                '%s\n') % inst)
                 ui.print_exc()
Exemplo n.º 3
0
def status(args):
    data = {'request': 'status'}
    received = client.query(data)
    wt = received.get('WaitingTasks')
    if wt != None: print('WaitingTasks[{}]'.format(wt))
    for key, status in sorted(received.items()):
        if (key != 'WaitingTasks'):
            print('{}: {}'.format(key, status))
Exemplo n.º 4
0
def local_sparql():
    if config.LOCAL_STORE:
        log.debug("Querying local store")
        q = request.form['query']
        log.debug(q)
        return query(q).serialize(format='json')
    else:
        log.warning("No local store configured")
Exemplo n.º 5
0
def local_sparql():
    if config.LOCAL_STORE:
        log.debug("Querying local store")
        q = request.form['query']
        log.debug(q)
        results = query(q).serialize(format='json')
        log.debug(results)
        return results
    else:
        log.warning("No local store configured")
Exemplo n.º 6
0
def pull(args):
    task_path = os.path.join(config.TMP_PATH, args.name, 'src')
    if not os.path.exists(task_path):
        print('[Error] 存在しないタスクです {}'.format(args.name))
        exit(1)

    dst_path = args.dst or args.name
    if os.path.exists(os.path.join(dst_path)):
        print('[Error] ディレクトリがすでに存在します {}'.format(args.dst))
        exit(1)

    # pull data
    shutil.move(task_path, dst_path)

    # pullが終わったことを伝える
    data = {
        'request': 'pulled',
        'name': args.name,
    }
    client.query(data)
Exemplo n.º 7
0
# -*- coding: utf-8 -*-
"""
Closer Program Ver.0.0.3
 Time-stamp: <2017-05-13 17:22:09 akira>
"""
from client import query

if __name__ == '__main__':
    query('Stop Server')
Exemplo n.º 8
0
def remove_task(task_id):

    stringquery = """NESTEDUPDATE tasks/%s/show NO""" % (task_id)

    return client.query(stringquery)
Exemplo n.º 9
0
def complete_task(task_id):

    stringquery = """NESTEDUPDATE tasks/%s/completed COMPLETE""" % (task_id)

    return client.query(stringquery)
Exemplo n.º 10
0
def update_id(task_id):

    incr_task_id = int(task_id)+1
    update_id = """UPDATEINT TASK_ID %s""" % (incr_task_id)
    client.query(update_id)
Exemplo n.º 11
0
def new_task(title, task_id):   
    normalized_title = unicodedata.normalize("NFKD", title).encode("ascii", "ignore")

    stringquery = """addto tasks {"task_id":"%s", "title":"%s", "completed":"NIL", "show": "YES"}""" % (task_id, normalized_title)

    return client.query(stringquery)
Exemplo n.º 12
0
def show_tasks():
    return client.query("GET TASKS")
Exemplo n.º 13
0
def query(instruction):
    return client.query(instruction)