Exemplo n.º 1
0
 def do_upload_command(self, argv, parser):
     worksheet_uuid = self.env_model.get_current_worksheet()
     help_text = 'bundle_type: [%s]' % ('|'.join(sorted(UPLOADED_TYPES)))
     parser.add_argument('bundle_type', help=help_text)
     parser.add_argument('path', help='path of the directory to upload')
     # Add metadata arguments for UploadedBundle and all of its subclasses.
     metadata_keys = set()
     metadata_util.add_arguments(UploadedBundle, metadata_keys, parser)
     for bundle_type in UPLOADED_TYPES:
         bundle_subclass = get_bundle_subclass(bundle_type)
         metadata_util.add_arguments(bundle_subclass, metadata_keys, parser)
     metadata_util.add_auto_argument(parser)
     args = parser.parse_args(argv)
     # Check that the upload path exists.
     path_util.check_isvalid(path_util.normalize(args.path), 'upload')
     # Pull out the upload bundle type from the arguments and validate it.
     if args.bundle_type not in UPLOADED_TYPES:
         raise UsageError('Invalid bundle type %s (options: [%s])' % (
           args.bundle_type, '|'.join(sorted(UPLOADED_TYPES)),
         ))
     bundle_subclass = get_bundle_subclass(args.bundle_type)
     metadata = metadata_util.request_missing_data(bundle_subclass, args)
     # Type-check the bundle metadata BEFORE uploading the bundle data.
     # This optimization will avoid file copies on failed bundle creations.
     bundle_subclass.construct(data_hash='', metadata=metadata).validate()
     print self.client.upload(args.bundle_type, args.path, metadata, worksheet_uuid)
Exemplo n.º 2
0
 def do_make_command(self, argv, parser):
     client, worksheet_uuid = self.manager.get_current_worksheet_uuid()
     parser.add_argument('target', help=self.TARGET_FORMAT, nargs='+')
     metadata_util.add_arguments(MakeBundle, set(), parser)
     metadata_util.add_auto_argument(parser)
     args = parser.parse_args(argv)
     targets = self.parse_key_targets(args.target)
     metadata = metadata_util.request_missing_data(MakeBundle, args)
     print client.make(targets, metadata, worksheet_uuid)
Exemplo n.º 3
0
 def do_run_old_command(self, argv, parser):
     client, worksheet_uuid = self.manager.get_current_worksheet_uuid()
     parser.add_argument('program_target', help=self.TARGET_FORMAT)
     parser.add_argument('input_target', help=self.TARGET_FORMAT)
     parser.add_argument(
       'command',
       help='shell command with access to program, input, and output',
     )
     metadata_util.add_arguments(RunBundle, set(), parser)
     metadata_util.add_auto_argument(parser)
     args = parser.parse_args(argv)
     program_target = self.parse_target(args.program_target, canonicalize=True)
     input_target = self.parse_target(args.input_target, canonicalize=True)
     metadata = metadata_util.request_missing_data(RunBundle, args)
     print client.run(program_target, input_target, args.command, metadata, worksheet_uuid)
Exemplo n.º 4
0
 def do_run_command(self, argv, parser):
     worksheet_uuid = self.env_model.get_current_worksheet()
     help = '[<uuid>|<name>][%s<subpath within bundle>]' % (os.sep,)
     parser.add_argument('program_target', help=help)
     parser.add_argument('input_target', help=help)
     parser.add_argument(
       'command',
       help='shell command with access to program, input, and output',
     )
     metadata_util.add_arguments(RunBundle, set(), parser)
     metadata_util.add_auto_argument(parser)
     args = parser.parse_args(argv)
     program_target = self.parse_target(args.program_target, canonicalize=True)
     input_target = self.parse_target(args.input_target, canonicalize=True)
     metadata = metadata_util.request_missing_data(RunBundle, args)
     print self.client.run(program_target, input_target, args.command, metadata, worksheet_uuid)
Exemplo n.º 5
0
 def do_run_command(self, argv, parser):
     client, worksheet_uuid = self.manager.get_current_worksheet_uuid()
     parser.add_argument('target', help=self.TARGET_FORMAT, nargs='*')
     parser.add_argument('command', help='Command-line')
     metadata_util.add_arguments(RunBundle, set(), parser)
     metadata_util.add_auto_argument(parser)
     args = parser.parse_args(argv)
     targets = self.parse_key_targets(args.target)
     command = args.command
     if False:
         # Expand command = "@svmlight/run" => "svmlight:svmlight svmlight/run"
         pattern = re.compile(r'^([^@]*)@([^@]+)@(.*)$')
         while True:
             m = pattern.match(command)
             if not m: break
             before, key, after = m
             targets[key] = self.parse_target(key, canonicalize=True)  # key is the target
             command = before + key + after
     #print targets, command
     metadata = metadata_util.request_missing_data(RunBundle, args)
     print client.run(targets, command, metadata, worksheet_uuid)
Exemplo n.º 6
0
 def do_make_command(self, argv, parser):
     worksheet_uuid = self.env_model.get_current_worksheet()
     help = '[<key>:][<uuid>|<name>][%s<subpath within bundle>]' % (os.sep,)
     parser.add_argument('target', help=help, nargs='+')
     metadata_util.add_arguments(MakeBundle, set(), parser)
     metadata_util.add_auto_argument(parser)
     args = parser.parse_args(argv)
     targets = {}
     # Turn targets into a dict mapping key -> (uuid, subpath)) tuples.
     for argument in args.target:
         if ':' in argument:
             (key, target) = argument.split(':', 1)
         else:
             # Provide syntactic sugar for a make bundle with a single anonymous target.
             (key, target) = ('', argument)
         if key in targets:
             if key:
                 raise UsageError('Duplicate key: %s' % (key,))
             else:
                 raise UsageError('Must specify keys when packaging multiple targets!')
         targets[key] = self.parse_target(target, canonicalize=True)
     metadata = metadata_util.request_missing_data(MakeBundle, args)
     print self.client.make(targets, metadata, worksheet_uuid)