Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(514)

Side by Side Diff: utils/pub/hosted_source.dart

Issue 11437019: Add logging system to pub and sprinkle some logging in. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweak output. Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/pub/git.dart ('k') | utils/pub/io.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library hosted_source; 5 library hosted_source;
6 6
7 import 'dart:io' as io; 7 import 'dart:io' as io;
8 import 'dart:json'; 8 import 'dart:json';
9 import 'dart:uri'; 9 import 'dart:uri';
10 10
11 // TODO(nweiz): Make this import better. 11 // TODO(nweiz): Make this import better.
12 import '../../pkg/http/lib/http.dart' as http; 12 import '../../pkg/http/lib/http.dart' as http;
13 import 'io.dart'; 13 import 'io.dart';
14 import 'log.dart' as log;
14 import 'package.dart'; 15 import 'package.dart';
15 import 'pubspec.dart'; 16 import 'pubspec.dart';
16 import 'source.dart'; 17 import 'source.dart';
17 import 'source_registry.dart'; 18 import 'source_registry.dart';
18 import 'utils.dart'; 19 import 'utils.dart';
19 import 'version.dart'; 20 import 'version.dart';
20 21
21 /** 22 /**
22 * A package source that installs packages from a package hosting site that 23 * A package source that installs packages from a package hosting site that
23 * uses the same API as pub.dartlang.org. 24 * uses the same API as pub.dartlang.org.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 /** 67 /**
67 * Downloads a package from the site and unpacks it. 68 * Downloads a package from the site and unpacks it.
68 */ 69 */
69 Future<bool> install(PackageId id, String destPath) { 70 Future<bool> install(PackageId id, String destPath) {
70 var parsedDescription = _parseDescription(id.description); 71 var parsedDescription = _parseDescription(id.description);
71 var name = parsedDescription.first; 72 var name = parsedDescription.first;
72 var url = parsedDescription.last; 73 var url = parsedDescription.last;
73 74
74 var fullUrl = "$url/packages/$name/versions/${id.version}.tar.gz"; 75 var fullUrl = "$url/packages/$name/versions/${id.version}.tar.gz";
75 76
76 print('Downloading $id...'); 77 log.message('Downloading $id...');
77 78
78 // Download and extract the archive to a temp directory. 79 // Download and extract the archive to a temp directory.
79 var tempDir; 80 var tempDir;
80 return Futures.wait([ 81 return Futures.wait([
81 httpClient.send(new http.Request("GET", new Uri.fromString(fullUrl))) 82 httpClient.send(new http.Request("GET", new Uri.fromString(fullUrl)))
82 .transform((response) => response.stream), 83 .transform((response) => response.stream),
83 systemCache.createTempDir() 84 systemCache.createTempDir()
84 ]).chain((args) { 85 ]).chain((args) {
85 tempDir = args[1]; 86 tempDir = args[1];
86 return timeout(extractTarGz(args[0], tempDir), HTTP_TIMEOUT, 87 return timeout(extractTarGz(args[0], tempDir), HTTP_TIMEOUT,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 169
169 var name = description["name"]; 170 var name = description["name"];
170 if (name is! String) { 171 if (name is! String) {
171 throw new FormatException("The 'name' key must have a string value."); 172 throw new FormatException("The 'name' key must have a string value.");
172 } 173 }
173 174
174 var url = description.containsKey("url") ? description["url"] : defaultUrl; 175 var url = description.containsKey("url") ? description["url"] : defaultUrl;
175 return new Pair<String, String>(name, url); 176 return new Pair<String, String>(name, url);
176 } 177 }
177 } 178 }
OLDNEW
« no previous file with comments | « utils/pub/git.dart ('k') | utils/pub/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698