예제 #1
0
    def execute(self, token, username):
        url = os.path.join(Tokenify.get_url(), 'workspace/')
        cookies = dict(username=username, token=token)
        query_string = '?name=' + self.workspace
        url = os.path.join(Tokenify.get_url(), 'workspaces/', query_string)
        body = dict(action='remove')

        #r, text = self.send_request('put', url, cookies=cookies, json=body)
        r, text = self.send_request('put', url, cookies=cookies, json=body)

        if r.status_code == 200 or r.status_code == 204:
            print('Workspace ' + text[0] + ' successfully removed. Status: ' +
                  text[1])
        else:
            print(str(r.status_code) + "---- HTTP REQUEST GET'S ERROR")
            print(text)
예제 #2
0
    def execute(self, token, username):
        url = os.path.join(Tokenify.get_url(), 'jobs/', str(self.id))
        cookies = dict(username=username, token=token)

        r, text = self.send_request('delete', url, cookies=cookies)

        if r.status_code == 200 or r.status_code == 204:
            print("Job canceled.")
        else:
            print(str(r.status_code) + "---- HTTP REQUEST GET'S ERROR")
            print(text)
예제 #3
0
파일: rights.py 프로젝트: mehsoy/jaws
    def execute(self, token, username):
        body = {'role': self.role}
        url = os.path.join(Tokenify.get_url(), 'users', str(self.user))
        cookies = dict(username=username, token=token)

        r, text = self.send_request('patch', url, cookies=cookies, json=body)

        if r.status_code == 200 or r.status_code == 204:
            print(self.user + ' set to ' + self.role + ' !')
        else:
            print(str(r.status_code) + "---- HTTP REQUEST GET'S ERROR")
            print(text)
예제 #4
0
파일: log.py 프로젝트: mehsoy/jaws
    def execute(self, token, username):
        parameters = {'status': 'DONE', 'days': str(self.days)}
        cookies = dict(username=username, token=token)

        if self.user is None:
            url = os.path.join(Tokenify.get_url(), 'users', username, 'jobs/')
        else:
            url = os.path.join(Tokenify.get_url(), 'users', str(self.user),
                               'jobs/')

        r, text = self.send_request('get',
                                    url,
                                    cookies=cookies,
                                    params=parameters)

        if r.status_code == 200 or r.status_code == 204:
            print("----- Log Overview -----")
            print(parse_to_list(text), end='')
        else:
            print(str(r.status_code) + "---- HTTP REQUEST GET'S ERROR")
            print(text)
예제 #5
0
    def execute(self, token, username):
        body = {'priority': self.priority}
        url = os.path.join(Tokenify.get_url(), 'jobs', str(self.id))
        cookies = dict(username=username, token=token)

        r, text = self.send_request('patch', url, cookies=cookies, json=body)

        if r.status_code == 200 or r.status_code == 204:
            print(text)
        else:
            print(str(r.status_code) + "---- HTTP REQUEST GET'S ERROR")
            print(text)
예제 #6
0
    def execute(self, token, username):
        cookies = dict(username=username, token=token)
        url = os.path.join(Tokenify.get_url(), 'workspaces', self.full_name,
                           'access')

        r, text = self.send_request('get', url, cookies=cookies)

        if 200 <= r.status_code < 300:
            print(text)
        else:
            print(str(r.status_code) + '---- HTTP GET ERROR')
            print(text)
예제 #7
0
파일: workers.py 프로젝트: mehsoy/jaws
    def execute(self, token, username):
        url = os.path.join(Tokenify.get_url(), 'workers/')
        cookies = dict(username=username, token=token)

        r, text = self.send_request('get', url, cookies=cookies)

        if r.status_code == 200 or r.status_code == 204:
            print("----- Worker Overview -----")
            print(parse_to_list(text))
        else:
            print(str(r.status_code) + "---- HTTP REQUEST GET'S ERROR")
            print(text)
예제 #8
0
    def execute(self, token, username):
        cookies = dict(username=username, token=token)
        parameters = {'status': ['ACTIVE', 'QUEUED']}
        if self.user is None and not self.all:
            url = os.path.join(Tokenify.get_url(), 'users', str(username),
                               'jobs/')
        elif self.all:
            url = os.path.join(Tokenify.get_url(), 'jobs/')
        else:
            url = os.path.join(Tokenify.get_url(), 'users', self.user, 'jobs/')

        r, text = self.send_request('get',
                                    url,
                                    cookies=cookies,
                                    params=parameters)

        if r.status_code == 200 or r.status_code == 204:
            print("----- Active Jobs -----")
            print(parse_to_list(text))
        else:
            print(str(r.status_code) + "---- HTTP REQUEST GET'S ERROR")
            print(text)
예제 #9
0
파일: deactivate.py 프로젝트: mehsoy/jaws
    def execute(self, token, username):
        body = {'status': 'DEACTIVATED'}
        cookies = dict(username=username, token=token)

        if self.object not in ['worker', 'master']:
            print("Object " + self.object + " not known")
            return

        elif self.object == 'worker':
            self.check_id(self.id)
            url = os.path.join(Tokenify.get_url(), 'workers', str(self.id))

        elif self.object == 'master':
            url = os.path.join(Tokenify.get_url(), 'master')

        r, text = self.send_request('patch', url, cookies=cookies, json=body)

        if r.status_code == 200 or r.status_code == 204:
            print(self.object + ' ' + str(self.id) + ' deactivated!')
        else:
            print(str(r.status_code) + "---- HTTP REQUEST GET'S ERROR")
            print(text)
예제 #10
0
    def execute(self, token, username):
        url = os.path.join(Tokenify.get_url(),
                           'configuration/' + self.configfile)
        cookies = dict(username=username, token=token)

        r, text = self.send_request('get', url, cookies=cookies)

        if r.status_code == 200 or r.status_code == 204:
            print("----- Config Overview of " + self.configfile + " -----")
            pp = pprint.PrettyPrinter(indent=4)
            pp.pprint(text)
        else:
            print(str(r.status_code) + "---- HTTP REQUEST GET'S ERROR")
            print(text)
예제 #11
0
    def execute(self, token, username):
        url = os.path.join(Tokenify.get_url(), 'jobs/')
        cookies = dict(username=username, token=token)
        parameters = {'status': 'QUEUED'}

        r, text = self.send_request('get',
                                    url,
                                    cookies=cookies,
                                    params=parameters)

        if r.status_code == 200 or r.status_code == 204:
            print("----- Queue Overview -----")
            print(parse_to_list(text))
        else:
            print(str(r.status_code) + "---- HTTP REQUEST GET'S ERROR")
            print(text)
예제 #12
0
    def execute(self, token, username):
        cookies = dict(username=username, token=token)
        url = os.path.join(Tokenify.get_url(), 'workspaces', self.full_name, 'access')
        data = { 
            'tag_type': self.tag_type,
            'name': self.name,
            'instruction': self.instruction
        }

        r, text = self.send_request('patch', url, cookies=cookies, json=data)

        if 200 <= r.status_code < 300:
            print(text)
        else:
            print(str(r.status_code) + '---- HTTP PATCH ERROR')
            print(text)
예제 #13
0
    def execute(self, token, username):
        url = os.path.join(Tokenify.get_url(), 'jobs/')
        cookies = dict(username=username, token=token)
        data = {'workspace': self.workspace,
                'target': self.target,
                'a': self.a,
                'b': self.b,
                'e': self.e,
                'for_user': self.user
                }

        r, text = self.send_request('post', url, cookies=cookies, json=data)

        if r.status_code == 200 or r.status_code == 204:
            print('The job\'s identifier is ' + str(text))
        else:
            print(str(r.status_code) + "---- HTTP REQUEST GET'S ERROR")
            print(text)
예제 #14
0
    def execute(self, token, username, ):
        args = self.args
        cookies = dict(username=username,token=token)
        params = dict()

        if args.command == 'list':
            user = args.user if args.user else username

            if args.storage and args.all:
                url = os.path.join(Tokenify.get_url(), 'storages', str(args.storage))
                params = {'dirs': 'True'}

            elif args.storage:
                url = os.path.join(Tokenify.get_url(), 'users', user, 'storages',
                                   str(args.storage))

            elif args.all:
                url = os.path.join(Tokenify.get_url(), 'storages/')
                params = {'dirs': 'True'}

            elif args.user or args.dirs:
                url = os.path.join(Tokenify.get_url(), 'users', user, 'storages/')

            else:
                # "dmd storage list" prints list of storages w/ info about them
                url = os.path.join(Tokenify.get_url(), 'storages/')
            r, text = self.send_request('get', url, cookies=cookies, params=params)

        elif args.command == 'set':
            url = os.path.join(Tokenify.get_url(), 'storages/', args.alias)
            p = re.compile('([^=])+=([^=])+').match(args.keyvalue)
            if not p:
                print('Bad syntax, can\'t process request')
                return
            key, value = args.keyvalue.split('=')
            body = dict(key=key, value=value)
            r, text = self.send_request('patch', url, cookies=cookies, json=body)
        else:
            print('Invalid command.')
            return

        if r.status_code == 200 or r.status_code == 204:
            print(parse_to_list(text))
        else:
            print(str(r.status_code) + "---- HTTP REQUEST GET'S ERROR")
            print(text)
예제 #15
0
    def execute(self, token, username):
        args = self.args
        cookies = dict(username=username, token=token)

        if args.command == 'list':
            url = os.path.join(Tokenify.get_url(), 'workspaces/')
            if not args.all: url += '?for_user='******'username']
            r, text = self.send_request('get', url, cookies=cookies)

        elif args.command == 'create':
            url = os.path.join(Tokenify.get_url(), 'workspaces/')
            body = dict(name=args.label)
            # if args.storage: body['storage'] = args.storage
            r, text = self.send_request('post',
                                        url,
                                        cookies=cookies,
                                        json=body)

        elif args.command == 'extend':
            query_string = '?name=' + args.full_name
            url = os.path.join(Tokenify.get_url(), 'workspaces/', query_string)
            body = dict(action='extend')
            r, text = self.send_request('put', url, cookies=cookies, json=body)

        elif args.command == 'remove':
            query_string = '?name=' + args.full_name
            url = os.path.join(Tokenify.get_url(), 'workspaces/', query_string)
            body = dict(action='remove')
            r, text = self.send_request('put', url, cookies=cookies, json=body)

        elif args.command == 'set':
            url = os.path.join(Tokenify.get_url(), 'workspaces/',
                               args.full_name)
            p = re.compile('([^=])+=([^=])+').match(args.keyvalue)
            if not p:
                print('Bad syntax, can\'t process request')
                return
            key, value = args.keyvalue.split('=')
            body = dict(key=key, value=value)
            r, text = self.send_request('patch',
                                        url,
                                        cookies=cookies,
                                        json=body)
        else:
            print('Invalid command.')
            return

        if r.status_code == 200 or r.status_code == 204:
            if args.command == 'list':
                print("Workspace Overview:")
                print(parse_to_list(text))
            if args.command == 'create':
                print('Created new Workspace ' + text)
            elif args.command == 'extend':
                print('Workspace ' + text[0] +
                      ' successfully extended. Time Remaining: ' + text[1])
            elif args.command == 'remove':
                print('Workspace ' + text[0] +
                      ' successfully removed. Status: ' + text[1])
        else:
            print(str(r.status_code) + "---- HTTP REQUEST GET'S ERROR")
            print(text)