Esempio n. 1
0
def split_path(path):
    colon_pos = get_first_pos_of_char(':', path)
    slash_pos = get_last_pos_of_char('/', path)
    project, path, name = path[:colon_pos], path[colon_pos+1:slash_pos], path[slash_pos+1:]
    if path == '':
        path = '/'
    project = unescape_colon(project)
    path = unescape_colon(path)
    name = unescape_colon(name).replace('\\/', '/')
    return project, path, name
Esempio n. 2
0
    def update_from_args(self, args):
        if args.filename is not None:
            try:
                if args.filename == "-":
                    data = sys.stdin.read()
                else:
                    with open(args.filename, 'r') as fd:
                        data = fd.read()
                self.update(
                    json.loads(data,
                               object_pairs_hook=collections.OrderedDict))
            except Exception as e:
                raise Exception('Error while parsing input JSON file: %s' %
                                unicode(e))

        if args.input_json is not None:
            try:
                self.update(
                    json.loads(args.input_json,
                               object_pairs_hook=collections.OrderedDict))
            except Exception as e:
                raise Exception('Error while parsing input JSON: %s' %
                                unicode(e))

        if args.input is not None:
            for keyeqval in args.input:
                try:
                    first_eq_pos = get_first_pos_of_char('=', keyeqval)
                    if first_eq_pos == -1:
                        raise
                    name = split_unescaped('=', keyeqval)[0]
                    value = keyeqval[first_eq_pos + 1:]
                except:
                    raise Exception(
                        'An input was found that did not conform to the syntax: -i<input name>=<input value>'
                    )
                self.add(self.executable._get_input_name(name) if \
                         self._desc.get('class') == 'workflow' else name, value)

        if self.input_spec is None:
            for i in self.inputs:
                if type(self.inputs[i]) == list and len(self.inputs[i]) == 1:
                    self.inputs[i] = self.inputs[i][0]

        # For now, we do not handle prompting for workflow inputs nor
        # recognizing when not all inputs haven't been bound
        if sys.stdout.isatty() and self._desc.get('class') != 'workflow':
            self.prompt_for_missing()
        elif self._desc.get('class') != 'workflow':
            missing_required_inputs = set(self.required_inputs) - set(
                self.inputs.keys())
            if missing_required_inputs:
                raise Exception(
                    'Some inputs (%s) are missing, and interactive mode is not available'
                    % (', '.join(missing_required_inputs)))
Esempio n. 3
0
def split_path(path):
    colon_pos = get_first_pos_of_char(':', path)
    slash_pos = get_last_pos_of_char('/', path)
    project, path, name = path[:colon_pos], path[colon_pos +
                                                 1:slash_pos], path[slash_pos +
                                                                    1:]
    if path == '':
        path = '/'
    project = unescape_colon(project)
    path = unescape_colon(path)
    name = unescape_colon(name).replace('\\/', '/')
    return project, path, name
Esempio n. 4
0
    def update_from_args(self, args, require_all_inputs=True):
        if args.filename is not None:
            try:
                if args.filename == "-":
                    data = sys.stdin.read()
                else:
                    with open(args.filename, 'r') as fd:
                        data = fd.read()
                self.update(json.loads(data, object_pairs_hook=collections.OrderedDict))
            except Exception as e:
                raise DXCLIError('Error while parsing input JSON file: %s' % unicode(e))

        if args.input_json is not None:
            try:
                self.update(json.loads(args.input_json, object_pairs_hook=collections.OrderedDict))
            except Exception as e:
                raise DXCLIError('Error while parsing input JSON: %s' % unicode(e))

        if args.input is not None:
            for keyeqval in args.input:
                try:
                    first_eq_pos = get_first_pos_of_char('=', keyeqval)
                    if first_eq_pos == -1:
                        raise
                    name = split_unescaped('=', keyeqval)[0]
                    value = keyeqval[first_eq_pos + 1:]
                except:
                    raise DXCLIError('An input was found that did not conform to the syntax: -i<input name>=<input value>')
                self.add(self.executable._get_input_name(name) if \
                         self._desc.get('class') == 'workflow' else name, value)

        if self.input_spec is None:
            for i in self.inputs:
                if type(self.inputs[i]) == list and len(self.inputs[i]) == 1:
                    self.inputs[i] = self.inputs[i][0]

        # For now, we do not handle prompting for workflow inputs nor
        # recognizing when not all inputs haven't been bound
        if require_all_inputs:
            if sys.stdout.isatty() and self._desc.get('class') != 'workflow':
                self.prompt_for_missing()
            elif self._desc.get('class') != 'workflow':
                missing_required_inputs = set(self.required_inputs) - set(self.inputs.keys())
                if missing_required_inputs:
                    raise DXCLIError('Some inputs (%s) are missing, and interactive mode is not available' % (', '.join(missing_required_inputs)))
Esempio n. 5
0
    def update_from_args(self, args):
        if args.filename is not None:
            try:
                if args.filename == "-":
                    data = sys.stdin.read()
                else:
                    with open(args.filename, 'r') as fd:
                        data = fd.read()
                self.update(json.loads(data, object_pairs_hook=collections.OrderedDict))
            except Exception as e:
                raise Exception('Error while parsing input JSON file: %s' % unicode(e))

        if args.input_json is not None:
            try:
                self.update(json.loads(args.input_json, object_pairs_hook=collections.OrderedDict))
            except Exception as e:
                raise Exception('Error while parsing input JSON: %s' % unicode(e))

        if args.input is not None:
            for keyeqval in args.input:
                try:
                    first_eq_pos = get_first_pos_of_char('=', keyeqval)
                    if first_eq_pos == -1:
                        raise
                    name = split_unescaped('=', keyeqval)[0]
                    value = keyeqval[first_eq_pos + 1:]
                except:
                    raise Exception('An input was found that did not conform to the syntax: -i<input name>=<input value>')
                self.add(name, value)

        if self.input_spec is None:
            for i in self.inputs:
                if type(self.inputs[i]) == list and len(self.inputs[i]) == 1:
                    self.inputs[i] = self.inputs[i][0]

        if sys.stdout.isatty():
            self.prompt_for_missing()
        else:
            missing_required_inputs = set(self.required_inputs) - set(self.inputs.keys())
            if missing_required_inputs:
                raise Exception('Some inputs (%s) are missing, and interactive mode is not available' % (', '.join(missing_required_inputs)))