Exemplo n.º 1
0
 def test_fix_url(self):
     data = [
         ('http://foo.com/', 'http://foo.com'),
         ('https://foo.com/', 'https://foo.com'),
         ('https://foo.com', 'https://foo.com'),
         ('https://foo.com/a', 'https://foo.com/a'),
         ('https://foo.com/a/', 'https://foo.com/a'),
         ('https://foo.com:8080/a/', 'https://foo.com:8080/a'),
         ('foo.com', 'https://foo.com'),
         ('foo.com/', 'https://foo.com'),
         ('foo.com/a/', 'https://foo.com/a'),
     ]
     for value, expected in data:
         self.assertEqual(expected, net.fix_url(value))
Exemplo n.º 2
0
 def test_fix_url(self):
   data = [
     ('http://foo.com/', 'http://foo.com'),
     ('https://foo.com/', 'https://foo.com'),
     ('https://foo.com', 'https://foo.com'),
     ('https://foo.com/a', 'https://foo.com/a'),
     ('https://foo.com/a/', 'https://foo.com/a'),
     ('https://foo.com:8080/a/', 'https://foo.com:8080/a'),
     ('foo.com', 'https://foo.com'),
     ('foo.com:8080', 'https://foo.com:8080'),
     ('foo.com/', 'https://foo.com'),
     ('foo.com/a/', 'https://foo.com/a'),
   ]
   for value, expected in data:
     self.assertEqual(expected, net.fix_url(value))
Exemplo n.º 3
0
def main():
    parser = argparse.ArgumentParser(description=sys.modules[__name__].__doc__)
    parser.add_argument('hash1')
    parser.add_argument('hash2')
    parser.add_argument('--difftool',
                        '-d',
                        default='diff',
                        help='Diff tool to use.')
    parser.add_argument(
        '--isolate-server',
        '-I',
        default=os.environ.get('ISOLATE_SERVER', ''),
        help='URL of the Isolate Server to use. Defaults to the'
        'environment variable ISOLATE_SERVER if set. No '
        'need to specify https://, this is assumed.')
    parser.add_argument('--namespace',
                        default='default-gzip',
                        help='The namespace to use on the Isolate Server, '
                        'default: %(default)s')
    parser.add_argument('--workdir',
                        '-w',
                        help='Working directory to use. If not specified, a '
                        'tmp dir is created.')
    args = parser.parse_args()

    if not args.isolate_server:
        parser.error('--isolate-server is required.')
    try:
        args.isolate_server = net.fix_url(args.isolate_server)
    except ValueError as e:
        parser.error('--isolate-server %s' % e)

    using_tmp_dir = False
    if not args.workdir:
        using_tmp_dir = True
        args.workdir = tempfile.mkdtemp(prefix='diff_isolates')
    else:
        args.workdir = os.path.abspath(args.workdir)
    if not os.path.isdir(args.workdir):
        os.makedirs(args.workdir)

    try:
        return diff_isolates(args.hash1, args.hash2, args.workdir,
                             args.difftool, args.isolate_server,
                             args.namespace)
    finally:
        if using_tmp_dir:
            shutil.rmtree(args.workdir)
Exemplo n.º 4
0
  def _process_swarming(self, options):
    """Processes the --swarming option and aborts if not specified.

    Returns the identity as determined by the server.
    """
    if not options.swarming:
      self.error('--swarming is required.')
    try:
      options.swarming = net.fix_url(options.swarming)
    except ValueError as e:
      self.error('--swarming %s' % e)
    on_error.report_on_exception_exit(options.swarming)
    try:
      user = auth.ensure_logged_in(options.swarming)
    except ValueError as e:
      self.error(str(e))
    return user