author | Brock Pytlik <bpytlik@sun.com> |
Mon, 16 Aug 2010 16:48:50 -0700 | |
changeset 2026 | d1b30615bc99 |
parent 2021 | 267b01eedee0 |
child 2100 | 6a366b063036 |
permissions | -rw-r--r-- |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
2 |
# |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
4 |
# |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
8 |
# |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
13 |
# |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
19 |
# |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
21 |
# |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
22 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
23 |
# |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
24 |
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
25 |
# |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
26 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
27 |
import errno |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
28 |
import httplib |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
29 |
import os |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
30 |
import pycurl |
1952
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
31 |
import time |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
32 |
import urlparse |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
33 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
34 |
# Need to ignore SIGPIPE if using pycurl in NOSIGNAL mode. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
35 |
try: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
36 |
import signal |
1265
c700981b0af2
8656 build download hash check fails in Windows due to text mode open
Tom Mueller <Tom.Mueller@sun.com>
parents:
1264
diff
changeset
|
37 |
if hasattr(signal, "SIGPIPE"): |
c700981b0af2
8656 build download hash check fails in Windows due to text mode open
Tom Mueller <Tom.Mueller@sun.com>
parents:
1264
diff
changeset
|
38 |
signal.signal(signal.SIGPIPE, signal.SIG_IGN) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
39 |
except ImportError: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
40 |
pass |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
41 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
42 |
import pkg.client.api_errors as api_errors |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
43 |
import pkg.client.transport.exception as tx |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
44 |
import pkg.client.transport.fileobj as fileobj |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
45 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
46 |
from collections import deque |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
47 |
from pkg.client import global_settings |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
48 |
|
1961
ac6c030e2fa2
16131 HTTP 1.1 pipelining is worse than expected
johansen <johansen@opensolaris.org>
parents:
1952
diff
changeset
|
49 |
pipelined_protocols = () |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
50 |
response_protocols = ("ftp", "http", "https") |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
51 |
|
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
52 |
class TransportEngine(object): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
53 |
"""This is an abstract class. It shouldn't implement any |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
54 |
of the methods that it contains. Leave that to transport-specific |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
55 |
implementations.""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
56 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
57 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
58 |
class CurlTransportEngine(TransportEngine): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
59 |
"""Concrete class of TransportEngine for libcurl transport.""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
60 |
|
1961
ac6c030e2fa2
16131 HTTP 1.1 pipelining is worse than expected
johansen <johansen@opensolaris.org>
parents:
1952
diff
changeset
|
61 |
def __init__(self, transport, max_conn=20): |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
62 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
63 |
# Backpointer to transport object |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
64 |
self.__xport = transport |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
65 |
# Curl handles |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
66 |
self.__mhandle = pycurl.CurlMulti() |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
67 |
self.__chandles = [] |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
68 |
self.__active_handles = 0 |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
69 |
self.__max_handles = max_conn |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
70 |
# Request queue |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
71 |
self.__req_q = deque() |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
72 |
# List of failures |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
73 |
self.__failures = [] |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
74 |
# List of URLs successfully transferred |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
75 |
self.__success = [] |
1717
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
76 |
# List of Orphaned URLs. |
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
77 |
self.__orphans = set() |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
78 |
# Set default file buffer size at 128k, callers override |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
79 |
# this setting after looking at VFS block size. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
80 |
self.__file_bufsz = 131072 |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
81 |
# Header bits and pieces |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
82 |
self.__user_agent = None |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
83 |
self.__common_header = {} |
1952
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
84 |
self.__last_stall_check = 0 |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
85 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
86 |
# Set options on multi-handle |
1961
ac6c030e2fa2
16131 HTTP 1.1 pipelining is worse than expected
johansen <johansen@opensolaris.org>
parents:
1952
diff
changeset
|
87 |
self.__mhandle.setopt(pycurl.M_PIPELINING, 0) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
88 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
89 |
# initialize easy handles |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
90 |
for i in range(self.__max_handles): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
91 |
eh = pycurl.Curl() |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
92 |
eh.url = None |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
93 |
eh.repourl = None |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
94 |
eh.fobj = None |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
95 |
eh.r_fobj = None |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
96 |
eh.filepath = None |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
97 |
eh.success = False |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
98 |
eh.fileprog = None |
1307
0a5427c74420
10685 Set file mtime according to server's last-modified
johansen <johansen@sun.com>
parents:
1298
diff
changeset
|
99 |
eh.filetime = -1 |
1952
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
100 |
eh.starttime = -1 |
1717
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
101 |
eh.uuid = None |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
102 |
self.__chandles.append(eh) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
103 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
104 |
# copy handles into handle freelist |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
105 |
self.__freehandles = self.__chandles[:] |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
106 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
107 |
def __call_perform(self): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
108 |
"""An internal method that invokes the multi-handle's |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
109 |
perform method.""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
110 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
111 |
while 1: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
112 |
ret, active_handles = self.__mhandle.perform() |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
113 |
if ret != pycurl.E_CALL_MULTI_PERFORM: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
114 |
break |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
115 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
116 |
self.__active_handles = active_handles |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
117 |
return ret |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
118 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
119 |
def add_url(self, url, filepath=None, writefunc=None, header=None, |
1472
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1448
diff
changeset
|
120 |
progclass=None, progtrack=None, sslcert=None, sslkey=None, |
1991
47ef443bd9b9
16607 depot error response not included in operation failure messages
johansen <johansen@opensolaris.org>
parents:
1974
diff
changeset
|
121 |
repourl=None, compressible=False, sock_path=None, failonerror=True): |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
122 |
"""Add a URL to the transport engine. Caller must supply |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
123 |
either a filepath where the file should be downloaded, |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
124 |
or a callback to a function that will peform the write. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
125 |
It may also optionally supply header information |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
126 |
in a dictionary. If the caller has a ProgressTracker, |
1472
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1448
diff
changeset
|
127 |
it should pass the tracker in progtrack. The caller should |
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1448
diff
changeset
|
128 |
also supply a class that wraps the tracker in progclass.""" |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
129 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
130 |
t = TransportRequest(url, filepath=filepath, |
1472
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1448
diff
changeset
|
131 |
writefunc=writefunc, header=header, progclass=progclass, |
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1448
diff
changeset
|
132 |
progtrack=progtrack, sslcert=sslcert, sslkey=sslkey, |
1937
be8995c7bb8f
10924 Want ability to communicate over unix sockets
johansen <johansen@opensolaris.org>
parents:
1895
diff
changeset
|
133 |
repourl=repourl, compressible=compressible, |
1991
47ef443bd9b9
16607 depot error response not included in operation failure messages
johansen <johansen@opensolaris.org>
parents:
1974
diff
changeset
|
134 |
sock_path=sock_path, failonerror=failonerror) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
135 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
136 |
self.__req_q.appendleft(t) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
137 |
|
1952
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
138 |
def __check_for_stalls(self): |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
139 |
"""In some situations, libcurl can get itself |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
140 |
tied in a knot, and fail to make progress. Check that the |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
141 |
active handles are making progress. If none of the active |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
142 |
handles have downloaded any content for the timeout period, |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
143 |
reset the transport and generate exceptions for the failed |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
144 |
requests.""" |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
145 |
|
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
146 |
current_time = time.time() |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
147 |
timeout = global_settings.PKG_CLIENT_LOWSPEED_TIMEOUT |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
148 |
time_list = [] |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
149 |
size_list = [] |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
150 |
failures = [] |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
151 |
q_hdls = [ |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
152 |
hdl for hdl in self.__chandles |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
153 |
if hdl not in self.__freehandles |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
154 |
] |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
155 |
|
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
156 |
# time.time() is based upon system clock. Check that |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
157 |
# our time hasn't been set backwards. If time is set forward, |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
158 |
# we'll have to expire the handles. There's no way to detect |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
159 |
# this until python properly implements gethrtime(). Solaris |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
160 |
# implementations of time.clock() appear broken. |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
161 |
|
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
162 |
for h in q_hdls: |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
163 |
time_elapsed = current_time - h.starttime |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
164 |
if time_elapsed < 0: |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
165 |
h.starttime = current_time |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
166 |
time_elapsed = 0 |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
167 |
size_xfrd = h.getinfo(pycurl.SIZE_DOWNLOAD) + \ |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
168 |
h.getinfo(pycurl.SIZE_UPLOAD) |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
169 |
time_list.append(time_elapsed) |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
170 |
size_list.append(size_xfrd) |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
171 |
|
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
172 |
# If timeout is smaller than smallest elapsed time, |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
173 |
# and no data has been transferred, abort. |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
174 |
if timeout < min(time_list) and max(size_list) == 0: |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
175 |
for h in q_hdls: |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
176 |
url = h.url |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
177 |
uuid = h.uuid |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
178 |
urlstem = h.repourl |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
179 |
ex = tx.TransportStallError(url, |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
180 |
repourl=urlstem, uuid=uuid) |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
181 |
|
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
182 |
self.__mhandle.remove_handle(h) |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
183 |
self.__teardown_handle(h) |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
184 |
self.__freehandles.append(h) |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
185 |
|
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
186 |
failures.append(ex) |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
187 |
|
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
188 |
self.__failures.extend(failures) |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
189 |
|
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
190 |
|
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
191 |
def __cleanup_requests(self): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
192 |
"""Cleanup handles that have finished their request. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
193 |
Return the handles to the freelist. Generate any |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
194 |
relevant error information.""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
195 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
196 |
count, good, bad = self.__mhandle.info_read() |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
197 |
failures = self.__failures |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
198 |
success = self.__success |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
199 |
done_handles = [] |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
200 |
ex_to_raise = None |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
201 |
visited_repos = set() |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
202 |
errors_seen = 0 |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
203 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
204 |
for h, en, em in bad: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
205 |
# Get statistics for each handle. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
206 |
repostats = self.__xport.stats[h.repourl] |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
207 |
visited_repos.add(repostats) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
208 |
repostats.record_tx() |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
209 |
nbytes = h.getinfo(pycurl.SIZE_DOWNLOAD) |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
210 |
seconds = h.getinfo(pycurl.TOTAL_TIME) |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
211 |
conn_count = h.getinfo(pycurl.NUM_CONNECTS) |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
212 |
conn_time = h.getinfo(pycurl.CONNECT_TIME) |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
213 |
|
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
214 |
url = h.url |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
215 |
uuid = h.uuid |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
216 |
urlstem = h.repourl |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
217 |
proto = urlparse.urlsplit(url)[0] |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
218 |
|
1961
ac6c030e2fa2
16131 HTTP 1.1 pipelining is worse than expected
johansen <johansen@opensolaris.org>
parents:
1952
diff
changeset
|
219 |
# When using pipelined operations, libcurl tracks the |
ac6c030e2fa2
16131 HTTP 1.1 pipelining is worse than expected
johansen <johansen@opensolaris.org>
parents:
1952
diff
changeset
|
220 |
# amount of time taken for the entire pipelined request |
ac6c030e2fa2
16131 HTTP 1.1 pipelining is worse than expected
johansen <johansen@opensolaris.org>
parents:
1952
diff
changeset
|
221 |
# as opposed to just the amount of time for a single |
ac6c030e2fa2
16131 HTTP 1.1 pipelining is worse than expected
johansen <johansen@opensolaris.org>
parents:
1952
diff
changeset
|
222 |
# file in the pipeline. So, if the connection time is 0 |
ac6c030e2fa2
16131 HTTP 1.1 pipelining is worse than expected
johansen <johansen@opensolaris.org>
parents:
1952
diff
changeset
|
223 |
# for a request using http(s), then it was pipelined and |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
224 |
# the total time must be obtained by subtracting the |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
225 |
# time the transfer of the individual request started |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
226 |
# from the total time. |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
227 |
if conn_time == 0 and proto in pipelined_protocols: |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
228 |
# Only performing this subtraction when the |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
229 |
# conn_time is 0 allows the first request in |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
230 |
# the pipeline to properly include connection |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
231 |
# time, etc. to initiate the transfer. |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
232 |
seconds -= h.getinfo(pycurl.STARTTRANSFER_TIME) |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
233 |
elif conn_time > 0: |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
234 |
seconds -= conn_time |
1570
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
235 |
|
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
236 |
# Sometimes libcurl will report no transfer time. |
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
237 |
# In that case, just use starttransfer time if it's |
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
238 |
# non-zero. |
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
239 |
if seconds < 0: |
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
240 |
seconds = h.getinfo(pycurl.STARTTRANSFER_TIME) |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
241 |
|
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
242 |
repostats.record_progress(nbytes, seconds) |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
243 |
|
1570
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
244 |
# Only count connections if the connection time is |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
245 |
# positive for http(s); for all other protocols, |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
246 |
# record the connection regardless. |
1570
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
247 |
if conn_count > 0 and conn_time > 0: |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
248 |
repostats.record_connection(conn_time) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
249 |
|
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
250 |
respcode = h.getinfo(pycurl.RESPONSE_CODE) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
251 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
252 |
# If we were cancelled, raise an API error. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
253 |
# Otherwise fall through to transport's exception |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
254 |
# generation. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
255 |
if en == pycurl.E_ABORTED_BY_CALLBACK: |
1218
49cd5492effc
9996 Exception thrown after cancel of install
johansen <johansen@sun.com>
parents:
1191
diff
changeset
|
256 |
ex = None |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
257 |
ex_to_raise = api_errors.CanceledException |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
258 |
elif en in (pycurl.E_HTTP_RETURNED_ERROR, |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
259 |
pycurl.E_FILE_COULDNT_READ_FILE): |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
260 |
# E_HTTP_RETURNED_ERROR is only used for http:// |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
261 |
# and https://, but a more specific reason for |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
262 |
# failure can be obtained from respcode. |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
263 |
# |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
264 |
# E_FILE_COULDNT_READ_FILE is only used for |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
265 |
# file://, but unfortunately can mean ENOENT, |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
266 |
# EPERM, etc. and libcurl doesn't differentiate |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
267 |
# or provide a respcode. |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
268 |
if proto not in response_protocols: |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
269 |
# For protocols that don't provide a |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
270 |
# pycurl.RESPONSE_CODE, use the |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
271 |
# pycurl error number instead. |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
272 |
respcode = en |
1693
1d855833b718
3720 Race condition exists for cancelation using the API
johansen <johansen@sun.com>
parents:
1634
diff
changeset
|
273 |
proto_reason = None |
1570
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
274 |
if proto in tx.proto_code_map: |
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
275 |
# Look up protocol error code map |
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
276 |
# from transport exception's table. |
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
277 |
pmap = tx.proto_code_map[proto] |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
278 |
if respcode in pmap: |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
279 |
proto_reason = pmap[respcode] |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
280 |
ex = tx.TransportProtoError(proto, respcode, |
1717
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
281 |
url, reason=proto_reason, repourl=urlstem, |
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
282 |
uuid=uuid) |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
283 |
repostats.record_error(decayable=ex.decayable) |
1570
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
284 |
errors_seen += 1 |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
285 |
else: |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
286 |
timeout = en == pycurl.E_OPERATION_TIMEOUTED |
1570
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
287 |
ex = tx.TransportFrameworkError(en, url, em, |
1717
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
288 |
repourl=urlstem, uuid=uuid) |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
289 |
repostats.record_error(decayable=ex.decayable, |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
290 |
timeout=timeout) |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
291 |
errors_seen += 1 |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
292 |
|
1218
49cd5492effc
9996 Exception thrown after cancel of install
johansen <johansen@sun.com>
parents:
1191
diff
changeset
|
293 |
if ex and ex.retryable: |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
294 |
failures.append(ex) |
1218
49cd5492effc
9996 Exception thrown after cancel of install
johansen <johansen@sun.com>
parents:
1191
diff
changeset
|
295 |
elif ex and not ex_to_raise: |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
296 |
ex_to_raise = ex |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
297 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
298 |
done_handles.append(h) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
299 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
300 |
for h in good: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
301 |
# Get statistics for each handle. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
302 |
repostats = self.__xport.stats[h.repourl] |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
303 |
visited_repos.add(repostats) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
304 |
repostats.record_tx() |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
305 |
nbytes = h.getinfo(pycurl.SIZE_DOWNLOAD) |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
306 |
seconds = h.getinfo(pycurl.TOTAL_TIME) |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
307 |
conn_count = h.getinfo(pycurl.NUM_CONNECTS) |
1570
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
308 |
conn_time = h.getinfo(pycurl.CONNECT_TIME) |
1307
0a5427c74420
10685 Set file mtime according to server's last-modified
johansen <johansen@sun.com>
parents:
1298
diff
changeset
|
309 |
h.filetime = h.getinfo(pycurl.INFO_FILETIME) |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
310 |
|
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
311 |
url = h.url |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
312 |
uuid = h.uuid |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
313 |
urlstem = h.repourl |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
314 |
proto = urlparse.urlsplit(url)[0] |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
315 |
|
1961
ac6c030e2fa2
16131 HTTP 1.1 pipelining is worse than expected
johansen <johansen@opensolaris.org>
parents:
1952
diff
changeset
|
316 |
# When using pipelined operations, libcurl tracks the |
ac6c030e2fa2
16131 HTTP 1.1 pipelining is worse than expected
johansen <johansen@opensolaris.org>
parents:
1952
diff
changeset
|
317 |
# amount of time taken for the entire pipelined request |
ac6c030e2fa2
16131 HTTP 1.1 pipelining is worse than expected
johansen <johansen@opensolaris.org>
parents:
1952
diff
changeset
|
318 |
# as opposed to just the amount of time for a single |
ac6c030e2fa2
16131 HTTP 1.1 pipelining is worse than expected
johansen <johansen@opensolaris.org>
parents:
1952
diff
changeset
|
319 |
# file in the pipeline. So, if the connection time is 0 |
ac6c030e2fa2
16131 HTTP 1.1 pipelining is worse than expected
johansen <johansen@opensolaris.org>
parents:
1952
diff
changeset
|
320 |
# for a request using http(s), then it was pipelined and |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
321 |
# the total time must be obtained by subtracting the |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
322 |
# time the transfer of the individual request started |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
323 |
# from the total time. |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
324 |
if conn_time == 0 and proto in pipelined_protocols: |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
325 |
# Only performing this subtraction when the |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
326 |
# conn_time is 0 allows the first request in |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
327 |
# the pipeline to properly include connection |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
328 |
# time, etc. to initiate the transfer and |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
329 |
# the correct calculations of bytespersec. |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
330 |
seconds -= h.getinfo(pycurl.STARTTRANSFER_TIME) |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
331 |
elif conn_time > 0: |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
332 |
seconds -= conn_time |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
333 |
|
1570
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
334 |
if seconds > 0: |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
335 |
bytespersec = nbytes / seconds |
1570
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
336 |
else: |
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
337 |
bytespersec = 0 |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
338 |
|
1570
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
339 |
# If a request ahead of a successful request fails due |
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
340 |
# to a timeout, sometimes libcurl will report impossibly |
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
341 |
# large total time values. In this case, check that the |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
342 |
# nbytes/sec exceeds our minimum threshold. If it does |
1570
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
343 |
# not, and the total time is longer than our timeout, |
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
344 |
# discard the time calculation as it is bogus. |
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
345 |
if (bytespersec < |
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
346 |
global_settings.pkg_client_lowspeed_limit) and ( |
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
347 |
seconds > |
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
348 |
global_settings.PKG_CLIENT_LOWSPEED_TIMEOUT): |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
349 |
nbytes = 0 |
1570
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
350 |
seconds = 0 |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
351 |
repostats.record_progress(nbytes, seconds) |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
352 |
|
1570
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
353 |
# Only count connections if the connection time is |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
354 |
# positive for http(s); for all other protocols, |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
355 |
# record the connection regardless. |
1570
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
356 |
if conn_count > 0 and conn_time > 0: |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
357 |
repostats.record_connection(conn_time) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
358 |
|
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
359 |
respcode = h.getinfo(pycurl.RESPONSE_CODE) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
360 |
|
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
361 |
if proto not in response_protocols or \ |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
362 |
respcode == httplib.OK: |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
363 |
h.success = True |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
364 |
repostats.clear_consecutive_errors() |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
365 |
success.append(url) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
366 |
else: |
1693
1d855833b718
3720 Race condition exists for cancelation using the API
johansen <johansen@sun.com>
parents:
1634
diff
changeset
|
367 |
proto_reason = None |
1570
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
368 |
if proto in tx.proto_code_map: |
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
369 |
# Look up protocol error code map |
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
370 |
# from transport exception's table. |
838ff2534e0b
13199 transport quality fails to avoid offline hosts
johansen <johansen@sun.com>
parents:
1569
diff
changeset
|
371 |
pmap = tx.proto_code_map[proto] |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
372 |
if respcode in pmap: |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
373 |
proto_reason = pmap[respcode] |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
374 |
ex = tx.TransportProtoError(proto, |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
375 |
respcode, url, reason=proto_reason, |
1717
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
376 |
repourl=urlstem, uuid=uuid) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
377 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
378 |
# If code >= 400, record this as an error. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
379 |
# Handlers above the engine get to decide |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
380 |
# for 200/300 codes that aren't OK |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
381 |
if respcode >= 400: |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
382 |
repostats.record_error( |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
383 |
decayable=ex.decayable) |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
384 |
errors_seen += 1 |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
385 |
# If code == 0, libcurl failed to read |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
386 |
# any HTTP status. Response is almost |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
387 |
# certainly corrupted. |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
388 |
elif respcode == 0: |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
389 |
repostats.record_error() |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
390 |
errors_seen += 1 |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
391 |
reason = "Invalid HTTP status code " \ |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
392 |
"from server" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
393 |
ex = tx.TransportProtoError(proto, |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
394 |
url=url, reason=reason, |
1717
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
395 |
repourl=urlstem, uuid=uuid) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
396 |
ex.retryable = True |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
397 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
398 |
# Stash retryable failures, arrange |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
399 |
# to raise first fatal error after |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
400 |
# cleanup. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
401 |
if ex.retryable: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
402 |
failures.append(ex) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
403 |
elif not ex_to_raise: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
404 |
ex_to_raise = ex |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
405 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
406 |
done_handles.append(h) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
407 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
408 |
# Call to remove_handle must be separate from info_read() |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
409 |
for h in done_handles: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
410 |
self.__mhandle.remove_handle(h) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
411 |
self.__teardown_handle(h) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
412 |
self.__freehandles.append(h) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
413 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
414 |
self.__failures = failures |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
415 |
self.__success = success |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
416 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
417 |
if ex_to_raise: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
418 |
raise ex_to_raise |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
419 |
|
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
420 |
# Don't bother to check the transient error count if no errors |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
421 |
# were encountered in this transaction. |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
422 |
if errors_seen == 0: |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
423 |
return |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
424 |
|
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
425 |
# If errors were encountered, but no exception raised, |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
426 |
# check if the maximum number of transient failures has |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
427 |
# been exceeded at any of the endpoints that were visited |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
428 |
# during this transaction. |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
429 |
for rs in visited_repos: |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
430 |
numce = rs.consecutive_errors |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
431 |
if numce >= \ |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
432 |
global_settings.PKG_CLIENT_MAX_CONSECUTIVE_ERROR: |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
433 |
# Reset consecutive error count before raising |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
434 |
# this exception. |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
435 |
rs.clear_consecutive_errors() |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
436 |
raise tx.ExcessiveTransientFailure(rs.url, |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
437 |
numce) |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
438 |
|
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
439 |
def check_status(self, urllist=None, good_reqs=False): |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
440 |
"""Return information about retryable failures that occured |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
441 |
during the request. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
442 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
443 |
This is a list of transport exceptions. Caller |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
444 |
may raise these, or process them for failure information. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
445 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
446 |
Urllist is an optional argument to return only failures |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
447 |
for a specific URLs. Not all callers of check status |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
448 |
want to claim the error state of all pending transactions. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
449 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
450 |
Transient errors are part of standard control flow. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
451 |
The caller will look at these and decide whether |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
452 |
to throw them or not. Permanent failures are raised |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
453 |
by the transport engine as soon as they occur. |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
454 |
|
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
455 |
If good_reqs is set to true, then check_stats will |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
456 |
return a tuple of lists, the first list contains the |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
457 |
transient errors that were encountered, the second list |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
458 |
contains successfully transferred urls. Because the |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
459 |
list of successfully transferred URLs may be long, |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
460 |
it is discarded if not requested by the caller.""" |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
461 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
462 |
# if list not specified, return all failures |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
463 |
if not urllist: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
464 |
rf = self.__failures |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
465 |
rs = self.__success |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
466 |
self.__failures = [] |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
467 |
self.__success = [] |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
468 |
|
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
469 |
if good_reqs: |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
470 |
return rf, rs |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
471 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
472 |
return rf |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
473 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
474 |
# otherwise, look for failures that match just the URLs |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
475 |
# in urllist. |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
476 |
rf = [ |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
477 |
tf |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
478 |
for tf in self.__failures |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
479 |
if hasattr(tf, "url") and tf.url in urllist |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
480 |
] |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
481 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
482 |
# remove failues in separate pass, or else for loop gets |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
483 |
# confused. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
484 |
for f in rf: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
485 |
self.__failures.remove(f) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
486 |
|
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
487 |
if not good_reqs: |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
488 |
self.__success = [] |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
489 |
return rf |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
490 |
|
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
491 |
rs = [] |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
492 |
|
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
493 |
for ts in self.__success: |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
494 |
if ts in urllist: |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
495 |
rs.append(ts) |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
496 |
|
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
497 |
for s in rs: |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
498 |
self.__success.remove(s) |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
499 |
|
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
500 |
return rf, rs |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
501 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
502 |
def get_url(self, url, header=None, sslcert=None, sslkey=None, |
1991
47ef443bd9b9
16607 depot error response not included in operation failure messages
johansen <johansen@opensolaris.org>
parents:
1974
diff
changeset
|
503 |
repourl=None, compressible=False, ccancel=None, sock_path=None, |
47ef443bd9b9
16607 depot error response not included in operation failure messages
johansen <johansen@opensolaris.org>
parents:
1974
diff
changeset
|
504 |
failonerror=True): |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
505 |
"""Invoke the engine to retrieve a single URL. Callers |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
506 |
wishing to obtain multiple URLs at once should use |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
507 |
addUrl() and run(). |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
508 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
509 |
getUrl will return a read-only file object that allows access |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
510 |
to the URL's data.""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
511 |
|
1569
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
512 |
fobj = fileobj.StreamingFileObj(url, self, ccancel=ccancel) |
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
513 |
progfunc = None |
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
514 |
|
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
515 |
if ccancel: |
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
516 |
progfunc = fobj.get_progress_func() |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
517 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
518 |
t = TransportRequest(url, writefunc=fobj.get_write_func(), |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
519 |
hdrfunc=fobj.get_header_func(), header=header, |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
520 |
sslcert=sslcert, sslkey=sslkey, repourl=repourl, |
1717
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
521 |
compressible=compressible, progfunc=progfunc, |
1991
47ef443bd9b9
16607 depot error response not included in operation failure messages
johansen <johansen@opensolaris.org>
parents:
1974
diff
changeset
|
522 |
uuid=fobj.uuid, sock_path=sock_path, |
47ef443bd9b9
16607 depot error response not included in operation failure messages
johansen <johansen@opensolaris.org>
parents:
1974
diff
changeset
|
523 |
failonerror=failonerror) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
524 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
525 |
self.__req_q.appendleft(t) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
526 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
527 |
return fobj |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
528 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
529 |
def get_url_header(self, url, header=None, sslcert=None, sslkey=None, |
1991
47ef443bd9b9
16607 depot error response not included in operation failure messages
johansen <johansen@opensolaris.org>
parents:
1974
diff
changeset
|
530 |
repourl=None, ccancel=None, sock_path=None, failonerror=True): |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
531 |
"""Invoke the engine to retrieve a single URL's headers. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
532 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
533 |
getUrlHeader will return a read-only file object that |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
534 |
contains no data.""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
535 |
|
1569
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
536 |
fobj = fileobj.StreamingFileObj(url, self, ccancel=ccancel) |
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
537 |
progfunc = None |
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
538 |
|
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
539 |
if ccancel: |
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
540 |
progfunc = fobj.get_progress_func() |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
541 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
542 |
t = TransportRequest(url, writefunc=fobj.get_write_func(), |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
543 |
hdrfunc=fobj.get_header_func(), header=header, |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
544 |
httpmethod="HEAD", sslcert=sslcert, sslkey=sslkey, |
1937
be8995c7bb8f
10924 Want ability to communicate over unix sockets
johansen <johansen@opensolaris.org>
parents:
1895
diff
changeset
|
545 |
repourl=repourl, progfunc=progfunc, uuid=fobj.uuid, |
1991
47ef443bd9b9
16607 depot error response not included in operation failure messages
johansen <johansen@opensolaris.org>
parents:
1974
diff
changeset
|
546 |
sock_path=sock_path, failonerror=failonerror) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
547 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
548 |
self.__req_q.appendleft(t) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
549 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
550 |
return fobj |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
551 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
552 |
@property |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
553 |
def pending(self): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
554 |
"""Returns true if the engine still has outstanding |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
555 |
work to perform, false otherwise.""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
556 |
|
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
557 |
return bool(self.__req_q) or self.__active_handles > 0 |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
558 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
559 |
def run(self): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
560 |
"""Run the transport engine. This polls the underlying |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
561 |
framework to complete any asynchronous I/O. Synchronous |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
562 |
operations should have completed when startRequest |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
563 |
was invoked.""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
564 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
565 |
if not self.pending: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
566 |
return |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
567 |
|
1264
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
568 |
if self.__active_handles > 0: |
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
569 |
# timeout returned in milliseconds |
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
570 |
timeout = self.__mhandle.timeout() |
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
571 |
if timeout == -1: |
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
572 |
# Pick our own timeout. |
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
573 |
timeout = 1.0 |
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
574 |
elif timeout > 0: |
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
575 |
# Timeout of 0 means skip call |
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
576 |
# to select. |
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
577 |
# |
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
578 |
# Convert from milliseconds to seconds. |
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
579 |
timeout = timeout / 1000.0 |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
580 |
|
1264
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
581 |
if timeout: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1307
diff
changeset
|
582 |
self.__mhandle.select(timeout) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
583 |
|
1717
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
584 |
# If object deletion has given the transport engine orphaned |
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
585 |
# requests to purge, do this first, in case the cleanup yields |
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
586 |
# free handles. |
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
587 |
while self.__orphans: |
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
588 |
url, uuid = self.__orphans.pop() |
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
589 |
self.remove_request(url, uuid) |
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
590 |
|
1264
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
591 |
while self.__freehandles and self.__req_q: |
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
592 |
t = self.__req_q.pop() |
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
593 |
eh = self.__freehandles.pop(-1) |
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
594 |
self.__setup_handle(eh, t) |
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
595 |
self.__mhandle.add_handle(eh) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
596 |
|
1264
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
597 |
self.__call_perform() |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
598 |
|
1264
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
599 |
self.__cleanup_requests() |
a4a5c41ce199
10243 Engine should call pycurl when select times out
johansen <johansen@sun.com>
parents:
1218
diff
changeset
|
600 |
|
1952
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
601 |
if self.__active_handles and (not self.__freehandles or not |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
602 |
self.__req_q): |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
603 |
cur_clock = time.time() |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
604 |
if cur_clock - self.__last_stall_check > 1: |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
605 |
self.__last_stall_check = cur_clock |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
606 |
self.__check_for_stalls() |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
607 |
elif cur_clock - self.__last_stall_check < 0: |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
608 |
self.__last_stall_check = cur_clock |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
609 |
self.__check_for_stalls() |
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
610 |
|
1717
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
611 |
def orphaned_request(self, url, uuid): |
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
612 |
"""Add the URL to the list of orphaned requests. Any URL in |
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
613 |
list will be removed from the transport next time run() is |
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
614 |
invoked. This is used by the fileobj's __del__ method |
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
615 |
to prevent unintended modifications to transport state |
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
616 |
when StreamingFileObjs that aren't close()'d get cleaned |
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
617 |
up.""" |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
618 |
|
1717
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
619 |
self.__orphans.add((url, uuid)) |
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
620 |
|
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
621 |
def remove_request(self, url, uuid): |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
622 |
"""In order to remove a request, it may be necessary |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
623 |
to walk all of the items in the request queue, all of the |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
624 |
currently active handles, and the list of any transient |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
625 |
failures. This is expensive, so only remove a request |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
626 |
if absolutely necessary.""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
627 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
628 |
for h in self.__chandles: |
1717
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
629 |
if h.url == url and h.uuid == uuid and \ |
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
630 |
h not in self.__freehandles: |
1780
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
631 |
try: |
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
632 |
self.__mhandle.remove_handle(h) |
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
633 |
except pycurl.error: |
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
634 |
# If cleanup is interrupted, it's |
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
635 |
# possible that a handle was removed but |
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
636 |
# not placed in freelist. In that case, |
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
637 |
# finish cleanup and appened to |
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
638 |
# freehandles. |
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
639 |
pass |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
640 |
self.__teardown_handle(h) |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
641 |
self.__freehandles.append(h) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
642 |
return |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
643 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
644 |
for i, t in enumerate(self.__req_q): |
1717
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
645 |
if t.url == url and t.uuid == uuid: |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
646 |
del self.__req_q[i] |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
647 |
return |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
648 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
649 |
for ex in self.__failures: |
1717
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
650 |
if ex.url == url and ex.uuid == uuid: |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
651 |
self.__failures.remove(ex) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
652 |
return |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
653 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
654 |
def reset(self): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
655 |
"""Reset the state of the transport engine. Do this |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
656 |
before performing another type of request.""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
657 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
658 |
for c in self.__chandles: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
659 |
if c not in self.__freehandles: |
1780
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
660 |
try: |
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
661 |
self.__mhandle.remove_handle(c) |
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
662 |
except pycurl.error: |
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
663 |
# If cleanup is interrupted, it's |
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
664 |
# possible that a handle was removed but |
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
665 |
# not placed in freelist. In that case, |
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
666 |
# finish cleanup and appened to |
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
667 |
# freehandles. |
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
668 |
pass |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
669 |
self.__teardown_handle(c) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
670 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
671 |
self.__active_handles = 0 |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
672 |
self.__freehandles = self.__chandles[:] |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
673 |
self.__req_q = deque() |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
674 |
self.__failures = [] |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
675 |
self.__success = [] |
1717
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
676 |
self.__orphans = set() |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
677 |
|
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
678 |
def send_data(self, url, data=None, header=None, sslcert=None, |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
679 |
sslkey=None, repourl=None, ccancel=None, sock_path=None, |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
2021
diff
changeset
|
680 |
data_fobj=None, data_fp=None, failonerror=True): |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
681 |
"""Invoke the engine to retrieve a single URL. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
682 |
This routine sends the data in data, and returns the |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
683 |
server's response. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
684 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
685 |
Callers wishing to obtain multiple URLs at once should use |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
686 |
addUrl() and run(). |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
687 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
688 |
sendData will return a read-only file object that allows access |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
689 |
to the server's response..""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
690 |
|
1569
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
691 |
fobj = fileobj.StreamingFileObj(url, self, ccancel=ccancel) |
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
692 |
progfunc = None |
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
693 |
|
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
694 |
if ccancel: |
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
695 |
progfunc = fobj.get_progress_func() |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
696 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
697 |
t = TransportRequest(url, writefunc=fobj.get_write_func(), |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
698 |
hdrfunc=fobj.get_header_func(), header=header, data=data, |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
699 |
httpmethod="POST", sslcert=sslcert, sslkey=sslkey, |
1937
be8995c7bb8f
10924 Want ability to communicate over unix sockets
johansen <johansen@opensolaris.org>
parents:
1895
diff
changeset
|
700 |
repourl=repourl, progfunc=progfunc, uuid=fobj.uuid, |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
2021
diff
changeset
|
701 |
sock_path=None, read_fobj=data_fobj, read_filepath=data_fp, |
1991
47ef443bd9b9
16607 depot error response not included in operation failure messages
johansen <johansen@opensolaris.org>
parents:
1974
diff
changeset
|
702 |
failonerror=failonerror) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
703 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
704 |
self.__req_q.appendleft(t) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
705 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
706 |
return fobj |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
707 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
708 |
def set_file_bufsz(self, size): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
709 |
"""If the downloaded files are being written out by |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
710 |
the file() mechanism, and not written using a callback, |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
711 |
the I/O is buffered. Set the buffer size using |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
712 |
this function. If it's not set, a default of 131072 (128k) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
713 |
is used.""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
714 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
715 |
if size <= 0: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
716 |
self.__file_bufsz = 8192 |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
717 |
return |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
718 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
719 |
self.__file_bufsz = size |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
720 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
721 |
def set_header(self, hdrdict=None): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
722 |
"""Supply a dictionary of name/value pairs in hdrdict. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
723 |
These will be included on all requests issued by the transport |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
724 |
engine. To append a specific header to a certain request, |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
725 |
supply a dictionary to the header argument of addUrl.""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
726 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
727 |
if not hdrdict: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
728 |
self.__common_header = {} |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
729 |
return |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
730 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
731 |
self.__common_header = hdrdict |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
732 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
733 |
def set_user_agent(self, ua_str): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
734 |
"""Supply a string str and the transport engine will |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
735 |
use this string as its User-Agent header. This is |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
736 |
a header that will be common to all transport requests.""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
737 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
738 |
self.__user_agent = ua_str |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
739 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
740 |
def __setup_handle(self, hdl, treq): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
741 |
"""Setup the curl easy handle, hdl, with the parameters |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
742 |
specified in the TransportRequest treq. If global |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
743 |
parameters are set, apply these to the handle as well.""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
744 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
745 |
# Set nosignal, so timeouts don't crash client |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
746 |
hdl.setopt(pycurl.NOSIGNAL, 1) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
747 |
|
1218
49cd5492effc
9996 Exception thrown after cancel of install
johansen <johansen@sun.com>
parents:
1191
diff
changeset
|
748 |
# Set connect timeout. Its value is defined in global_settings. |
49cd5492effc
9996 Exception thrown after cancel of install
johansen <johansen@sun.com>
parents:
1191
diff
changeset
|
749 |
hdl.setopt(pycurl.CONNECTTIMEOUT, |
49cd5492effc
9996 Exception thrown after cancel of install
johansen <johansen@sun.com>
parents:
1191
diff
changeset
|
750 |
global_settings.PKG_CLIENT_CONNECT_TIMEOUT) |
49cd5492effc
9996 Exception thrown after cancel of install
johansen <johansen@sun.com>
parents:
1191
diff
changeset
|
751 |
|
49cd5492effc
9996 Exception thrown after cancel of install
johansen <johansen@sun.com>
parents:
1191
diff
changeset
|
752 |
# Set lowspeed limit and timeout. Clients that are too |
49cd5492effc
9996 Exception thrown after cancel of install
johansen <johansen@sun.com>
parents:
1191
diff
changeset
|
753 |
# slow or have hung after specified amount of time will |
49cd5492effc
9996 Exception thrown after cancel of install
johansen <johansen@sun.com>
parents:
1191
diff
changeset
|
754 |
# abort the connection. |
49cd5492effc
9996 Exception thrown after cancel of install
johansen <johansen@sun.com>
parents:
1191
diff
changeset
|
755 |
hdl.setopt(pycurl.LOW_SPEED_LIMIT, |
49cd5492effc
9996 Exception thrown after cancel of install
johansen <johansen@sun.com>
parents:
1191
diff
changeset
|
756 |
global_settings.pkg_client_lowspeed_limit) |
49cd5492effc
9996 Exception thrown after cancel of install
johansen <johansen@sun.com>
parents:
1191
diff
changeset
|
757 |
hdl.setopt(pycurl.LOW_SPEED_TIME, |
49cd5492effc
9996 Exception thrown after cancel of install
johansen <johansen@sun.com>
parents:
1191
diff
changeset
|
758 |
global_settings.PKG_CLIENT_LOWSPEED_TIMEOUT) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
759 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
760 |
# Follow redirects |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
761 |
hdl.setopt(pycurl.FOLLOWLOCATION, True) |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
762 |
# Set limit on maximum number of redirects |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
763 |
hdl.setopt(pycurl.MAXREDIRS, |
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
764 |
global_settings.PKG_CLIENT_MAX_REDIRECT) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
765 |
|
1280
9c577f0a6cd8
10411 Protect progress tracker against adversarial interfaces
johansen <johansen@sun.com>
parents:
1265
diff
changeset
|
766 |
# Make sure that we don't use a proxy if the destination |
9c577f0a6cd8
10411 Protect progress tracker against adversarial interfaces
johansen <johansen@sun.com>
parents:
1265
diff
changeset
|
767 |
# is localhost. |
9c577f0a6cd8
10411 Protect progress tracker against adversarial interfaces
johansen <johansen@sun.com>
parents:
1265
diff
changeset
|
768 |
hdl.setopt(pycurl.NOPROXY, "localhost") |
9c577f0a6cd8
10411 Protect progress tracker against adversarial interfaces
johansen <johansen@sun.com>
parents:
1265
diff
changeset
|
769 |
|
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
770 |
# Set user agent, if client has defined it |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
771 |
if self.__user_agent: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
772 |
hdl.setopt(pycurl.USERAGENT, self.__user_agent) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
773 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
774 |
# Take header dictionaries and convert them into lists |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
775 |
# of header strings. |
1448
ff6208d2ff22
10919 Perform downloads in smaller chunks
johansen <johansen@sun.com>
parents:
1431
diff
changeset
|
776 |
if self.__common_header or treq.header: |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
777 |
headerlist = [] |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
778 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
779 |
# Headers common to all requests |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
780 |
for k, v in self.__common_header.iteritems(): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
781 |
headerstr = "%s: %s" % (k, v) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
782 |
headerlist.append(headerstr) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
783 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
784 |
# Headers specific to this request |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
785 |
if treq.header: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
786 |
for k, v in treq.header.iteritems(): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
787 |
headerstr = "%s: %s" % (k, v) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
788 |
headerlist.append(headerstr) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
789 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
790 |
hdl.setopt(pycurl.HTTPHEADER, headerlist) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
791 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
792 |
# Set request url. Also set attribute on handle. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
793 |
hdl.setopt(pycurl.URL, treq.url) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
794 |
hdl.url = treq.url |
1717
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
795 |
hdl.uuid = treq.uuid |
1952
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
796 |
hdl.starttime = time.time() |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
797 |
# The repourl is the url stem that identifies the |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
798 |
# repository. This is useful to have around for coalescing |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
799 |
# error output, and statistics reporting. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
800 |
hdl.repourl = treq.repourl |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
801 |
if treq.filepath: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
802 |
try: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
803 |
hdl.fobj = open(treq.filepath, "wb+", |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
804 |
self.__file_bufsz) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
805 |
except EnvironmentError, e: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
806 |
if e.errno == errno.EACCES: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
807 |
raise api_errors.PermissionsException( |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
808 |
e.filename) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1307
diff
changeset
|
809 |
if e.errno == errno.EROFS: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1307
diff
changeset
|
810 |
raise api_errors.ReadOnlyFileSystemException( |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1307
diff
changeset
|
811 |
e.filename) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
812 |
# Raise OperationError if it's not EACCES |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1307
diff
changeset
|
813 |
# or EROFS. |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
814 |
raise tx.TransportOperationError( |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
815 |
"Unable to open file: %s" % e) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
816 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
817 |
hdl.setopt(pycurl.WRITEDATA, hdl.fobj) |
1307
0a5427c74420
10685 Set file mtime according to server's last-modified
johansen <johansen@sun.com>
parents:
1298
diff
changeset
|
818 |
# Request filetime, if endpoint knows it. |
0a5427c74420
10685 Set file mtime according to server's last-modified
johansen <johansen@sun.com>
parents:
1298
diff
changeset
|
819 |
hdl.setopt(pycurl.OPT_FILETIME, True) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
820 |
hdl.filepath = treq.filepath |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
821 |
elif treq.writefunc: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
822 |
hdl.setopt(pycurl.WRITEFUNCTION, treq.writefunc) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
823 |
hdl.filepath = None |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
824 |
hdl.fobj = None |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
825 |
else: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
826 |
raise tx.TransportOperationError("Transport invocation" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
827 |
" for URL %s did not specify filepath or write" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
828 |
" function." % treq.url) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
829 |
|
1991
47ef443bd9b9
16607 depot error response not included in operation failure messages
johansen <johansen@opensolaris.org>
parents:
1974
diff
changeset
|
830 |
if treq.failonerror: |
47ef443bd9b9
16607 depot error response not included in operation failure messages
johansen <johansen@opensolaris.org>
parents:
1974
diff
changeset
|
831 |
hdl.setopt(pycurl.FAILONERROR, True) |
47ef443bd9b9
16607 depot error response not included in operation failure messages
johansen <johansen@opensolaris.org>
parents:
1974
diff
changeset
|
832 |
|
1472
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1448
diff
changeset
|
833 |
if treq.progtrack and treq.progclass: |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
834 |
hdl.setopt(pycurl.NOPROGRESS, 0) |
1472
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1448
diff
changeset
|
835 |
hdl.fileprog = treq.progclass(treq.progtrack) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
836 |
hdl.setopt(pycurl.PROGRESSFUNCTION, |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
837 |
hdl.fileprog.progress_callback) |
1569
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
838 |
elif treq.progfunc: |
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
839 |
# For light-weight progress tracking / cancelation. |
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
840 |
hdl.setopt(pycurl.NOPROGRESS, 0) |
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
841 |
hdl.setopt(pycurl.PROGRESSFUNCTION, treq.progfunc) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
842 |
|
1937
be8995c7bb8f
10924 Want ability to communicate over unix sockets
johansen <johansen@opensolaris.org>
parents:
1895
diff
changeset
|
843 |
if treq.socket_path: |
be8995c7bb8f
10924 Want ability to communicate over unix sockets
johansen <johansen@opensolaris.org>
parents:
1895
diff
changeset
|
844 |
hdl.unix_socket(treq.socket_path) |
be8995c7bb8f
10924 Want ability to communicate over unix sockets
johansen <johansen@opensolaris.org>
parents:
1895
diff
changeset
|
845 |
|
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
846 |
proto = urlparse.urlsplit(treq.url)[0] |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
847 |
if not proto in ("http", "https"): |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
848 |
return |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
849 |
|
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
850 |
if treq.read_filepath: |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
851 |
try: |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
852 |
hdl.r_fobj = open(treq.read_filepath, "rb", |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
853 |
self.__file_bufsz) |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
854 |
except EnvironmentError, e: |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
855 |
if e.errno == errno.EACCES: |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
856 |
raise api_errors.PermissionsException( |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
857 |
e.filename) |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
858 |
# Raise OperationError if it's not EACCES |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
859 |
# or EROFS. |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
860 |
raise tx.TransportOperationError( |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
861 |
"Unable to open file: %s" % e) |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
862 |
|
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
863 |
if treq.compressible: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
864 |
hdl.setopt(pycurl.ENCODING, "") |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
865 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
866 |
if treq.hdrfunc: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
867 |
hdl.setopt(pycurl.HEADERFUNCTION, treq.hdrfunc) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
868 |
|
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
869 |
if treq.httpmethod == "GET": |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
870 |
hdl.setopt(pycurl.HTTPGET, True) |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
871 |
elif treq.httpmethod == "HEAD": |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
872 |
hdl.setopt(pycurl.NOBODY, True) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
873 |
elif treq.httpmethod == "POST": |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
874 |
hdl.setopt(pycurl.POST, True) |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
875 |
if treq.data is not None: |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
876 |
hdl.setopt(pycurl.POSTFIELDS, treq.data) |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
877 |
elif hdl.r_fobj or treq.read_fobj: |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
878 |
if not hdl.r_fobj: |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
879 |
hdl.r_fobj = treq.read_fobj |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
880 |
hdl.setopt(pycurl.READDATA, hdl.r_fobj) |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
881 |
hdl.setopt(pycurl.POSTFIELDSIZE, |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
882 |
os.fstat(hdl.r_fobj.fileno()).st_size) |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
883 |
else: |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
884 |
raise tx.TransportOperationError("Transport " |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
885 |
"operation for POST URL %s did not " |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
886 |
"supply data or read_fobj. At least one " |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
887 |
"is required." % treq.url) |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
888 |
elif treq.httpmethod == "PUT": |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
889 |
hdl.setopt(pycurl.UPLOAD, True) |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
890 |
if hdl.r_fobj or treq.read_fobj: |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
891 |
if not hdl.r_fobj: |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
892 |
hdl.r_fobj = treq.read_fobj |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
893 |
hdl.setopt(pycurl.READDATA, hdl.r_fobj) |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
894 |
hdl.setopt(pycurl.INFILESIZE, |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
895 |
os.fstat(hdl.r_fobj.fileno()).st_size) |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
896 |
else: |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
897 |
raise tx.TransportOperationError("Transport " |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
898 |
"operation for PUT URL %s did not " |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
899 |
"supply a read_fobj. One is required." |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
900 |
% treq.url) |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
901 |
elif treq.httpmethod == "DELETE": |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
902 |
hdl.setopt(pycurl.CUSTOMREQUEST, "DELETE") |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
903 |
else: |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
904 |
raise tx.TransportOperationError("Invalid http method " |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
905 |
"'%s' specified." % treq.httpmethod) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
906 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
907 |
# Set up SSL options |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
908 |
if treq.sslcert: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
909 |
hdl.setopt(pycurl.SSLCERT, treq.sslcert) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
910 |
if treq.sslkey: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
911 |
hdl.setopt(pycurl.SSLKEY, treq.sslkey) |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1780
diff
changeset
|
912 |
|
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
913 |
# Options that apply when SSL is enabled |
1634
915de177f257
13746 transport should close connections after download phase
johansen <johansen@sun.com>
parents:
1570
diff
changeset
|
914 |
if proto == "https": |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
915 |
# Verify that peer's CN matches CN on certificate |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
916 |
hdl.setopt(pycurl.SSL_VERIFYHOST, 2) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
917 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
918 |
cadir = self.__xport.get_ca_dir() |
2021
267b01eedee0
16765 pkg5 should stop delivering its own CA certificate
johansen <johansen@opensolaris.org>
parents:
1991
diff
changeset
|
919 |
hdl.setopt(pycurl.SSL_VERIFYPEER, 1) |
267b01eedee0
16765 pkg5 should stop delivering its own CA certificate
johansen <johansen@opensolaris.org>
parents:
1991
diff
changeset
|
920 |
hdl.setopt(pycurl.CAPATH, cadir) |
267b01eedee0
16765 pkg5 should stop delivering its own CA certificate
johansen <johansen@opensolaris.org>
parents:
1991
diff
changeset
|
921 |
hdl.unsetopt(pycurl.CAINFO) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
922 |
|
1634
915de177f257
13746 transport should close connections after download phase
johansen <johansen@sun.com>
parents:
1570
diff
changeset
|
923 |
def shutdown(self): |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
924 |
"""Shutdown the transport engine, perform cleanup.""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
925 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
926 |
for c in self.__chandles: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
927 |
c.close() |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
928 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
929 |
self.__chandles = None |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
930 |
self.__freehandles = None |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
931 |
self.__mhandle.close() |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
932 |
self.__mhandle = None |
1780
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
933 |
self.__req_q = None |
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
934 |
self.__failures = None |
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
935 |
self.__success = None |
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
936 |
self.__orphans = None |
539517f56bf2
14683 transport cleanup can fail causing client traceback
johansen <johansen@sun.com>
parents:
1717
diff
changeset
|
937 |
self.__active_handles = 0 |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
938 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
939 |
@staticmethod |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
940 |
def __teardown_handle(hdl): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
941 |
"""Cleanup any state that we've associated with this handle. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
942 |
After a handle has been torn down, it should still be valid |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
943 |
for use, but should have no previous state. To remove |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
944 |
handles from use completely, use __shutdown.""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
945 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
946 |
hdl.reset() |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
947 |
if hdl.fobj: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
948 |
hdl.fobj.close() |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
949 |
hdl.fobj = None |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
950 |
if not hdl.success: |
1298
3a9fa6e1e670
10480 corrupted download confuses progress tracker
johansen <johansen@sun.com>
parents:
1284
diff
changeset
|
951 |
if hdl.fileprog: |
3a9fa6e1e670
10480 corrupted download confuses progress tracker
johansen <johansen@sun.com>
parents:
1284
diff
changeset
|
952 |
hdl.fileprog.abort() |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
953 |
try: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
954 |
os.remove(hdl.filepath) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
955 |
except EnvironmentError, e: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
956 |
if e.errno != errno.ENOENT: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
957 |
raise \ |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
958 |
tx.TransportOperationError( |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
959 |
"Unable to remove file: %s" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
960 |
% e) |
1298
3a9fa6e1e670
10480 corrupted download confuses progress tracker
johansen <johansen@sun.com>
parents:
1284
diff
changeset
|
961 |
else: |
3a9fa6e1e670
10480 corrupted download confuses progress tracker
johansen <johansen@sun.com>
parents:
1284
diff
changeset
|
962 |
if hdl.fileprog: |
3a9fa6e1e670
10480 corrupted download confuses progress tracker
johansen <johansen@sun.com>
parents:
1284
diff
changeset
|
963 |
filesz = os.stat(hdl.filepath).st_size |
3a9fa6e1e670
10480 corrupted download confuses progress tracker
johansen <johansen@sun.com>
parents:
1284
diff
changeset
|
964 |
hdl.fileprog.commit(filesz) |
1307
0a5427c74420
10685 Set file mtime according to server's last-modified
johansen <johansen@sun.com>
parents:
1298
diff
changeset
|
965 |
if hdl.filepath and hdl.filetime > -1: |
0a5427c74420
10685 Set file mtime according to server's last-modified
johansen <johansen@sun.com>
parents:
1298
diff
changeset
|
966 |
# Set atime/mtime, if we were able to |
0a5427c74420
10685 Set file mtime according to server's last-modified
johansen <johansen@sun.com>
parents:
1298
diff
changeset
|
967 |
# figure it out. File action will |
0a5427c74420
10685 Set file mtime according to server's last-modified
johansen <johansen@sun.com>
parents:
1298
diff
changeset
|
968 |
# override this at install time, if the |
0a5427c74420
10685 Set file mtime according to server's last-modified
johansen <johansen@sun.com>
parents:
1298
diff
changeset
|
969 |
# action has a timestamp property. |
0a5427c74420
10685 Set file mtime according to server's last-modified
johansen <johansen@sun.com>
parents:
1298
diff
changeset
|
970 |
ft = hdl.filetime |
0a5427c74420
10685 Set file mtime according to server's last-modified
johansen <johansen@sun.com>
parents:
1298
diff
changeset
|
971 |
os.utime(hdl.filepath, (ft, ft)) |
1298
3a9fa6e1e670
10480 corrupted download confuses progress tracker
johansen <johansen@sun.com>
parents:
1284
diff
changeset
|
972 |
|
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
973 |
if hdl.r_fobj: |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
974 |
hdl.r_fobj.close() |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
975 |
hdl.r_fobj = None |
1298
3a9fa6e1e670
10480 corrupted download confuses progress tracker
johansen <johansen@sun.com>
parents:
1284
diff
changeset
|
976 |
|
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
977 |
hdl.url = None |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
978 |
hdl.repourl = None |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
979 |
hdl.success = False |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
980 |
hdl.filepath = None |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
981 |
hdl.fileprog = None |
1717
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
982 |
hdl.uuid = None |
1307
0a5427c74420
10685 Set file mtime according to server's last-modified
johansen <johansen@sun.com>
parents:
1298
diff
changeset
|
983 |
hdl.filetime = -1 |
1952
449cc5776c26
16241 transport needs inactivity timeout for queued handles
johansen <johansen@opensolaris.org>
parents:
1937
diff
changeset
|
984 |
hdl.starttime = -1 |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
985 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
986 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
987 |
class TransportRequest(object): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
988 |
"""A class that contains per-request information for the underlying |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
989 |
transport engines. This is used to set per-request options that |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
990 |
are used either by the framework, the transport, or both.""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
991 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
992 |
def __init__(self, url, filepath=None, writefunc=None, |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
993 |
hdrfunc=None, header=None, data=None, httpmethod="GET", |
1472
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1448
diff
changeset
|
994 |
progclass=None, progtrack=None, sslcert=None, sslkey=None, |
1937
be8995c7bb8f
10924 Want ability to communicate over unix sockets
johansen <johansen@opensolaris.org>
parents:
1895
diff
changeset
|
995 |
repourl=None, compressible=False, progfunc=None, uuid=None, |
1991
47ef443bd9b9
16607 depot error response not included in operation failure messages
johansen <johansen@opensolaris.org>
parents:
1974
diff
changeset
|
996 |
sock_path=None, read_fobj=None, read_filepath=None, |
47ef443bd9b9
16607 depot error response not included in operation failure messages
johansen <johansen@opensolaris.org>
parents:
1974
diff
changeset
|
997 |
failonerror=False): |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
998 |
"""Create a TransportRequest with the following parameters: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
999 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1000 |
url - The url that the transport engine should retrieve |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1001 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1002 |
filepath - If defined, the transport engine will download the |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1003 |
file to this path. If not defined, the caller should |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1004 |
supply a write function. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1005 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1006 |
writefunc - A function, supplied instead of filepath, that |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1007 |
reads the bytes supplied by the transport engine and writes |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1008 |
them somewhere for processing. This is a callback. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1009 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1010 |
hdrfunc - A callback for examining the contents of header |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1011 |
data in a response to a transport request. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1012 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1013 |
header - A dictionary of key/value pairs to be included |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1014 |
in the request's header. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1015 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1016 |
compressible - A boolean value that indicates whether |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1017 |
the content that is requested is a candidate for transport |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1018 |
level compression. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1019 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1020 |
data - If the request is sending a data payload, include |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1021 |
the data in this argument. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1022 |
|
1991
47ef443bd9b9
16607 depot error response not included in operation failure messages
johansen <johansen@opensolaris.org>
parents:
1974
diff
changeset
|
1023 |
failonerror - If the request returns a HTTP code >= 400, |
47ef443bd9b9
16607 depot error response not included in operation failure messages
johansen <johansen@opensolaris.org>
parents:
1974
diff
changeset
|
1024 |
terminate the request early, instead of running it to |
47ef443bd9b9
16607 depot error response not included in operation failure messages
johansen <johansen@opensolaris.org>
parents:
1974
diff
changeset
|
1025 |
completion. |
47ef443bd9b9
16607 depot error response not included in operation failure messages
johansen <johansen@opensolaris.org>
parents:
1974
diff
changeset
|
1026 |
|
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1027 |
httpmethod - If the request is a HTTP/HTTPS request, |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1028 |
this can override the default HTTP method of GET. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1029 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1030 |
progtrack - If the transport wants the engine to update |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1031 |
the progress of the download, supply a ProgressTracker |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1032 |
object in this argument. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1033 |
|
1472
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1448
diff
changeset
|
1034 |
progclass - If the transport was supplied with a ProgressTracker |
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1448
diff
changeset
|
1035 |
this must point to a class that knows how to wrap the progress |
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1448
diff
changeset
|
1036 |
tracking object in way that allows the transport to invoke |
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1448
diff
changeset
|
1037 |
the proper callbacks. The transport instantiates an object |
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1448
diff
changeset
|
1038 |
of this class before beginning the request. |
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1448
diff
changeset
|
1039 |
|
1569
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
1040 |
progfunc - A function to be used as a progress callback. |
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
1041 |
The preferred method is is use progtrack/progclass, but |
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
1042 |
light-weight implementations may use progfunc instead, |
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
1043 |
especially if they don't need per-file updates. |
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
1044 |
|
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
1045 |
read_filepath - If the request is sending a file, include |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
1046 |
the path here, as this is the most efficient way to send |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
1047 |
the data. |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
1048 |
|
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
1049 |
read_fobj - If the request is sending a large payload, |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
1050 |
this points to a fileobject from which the data may be |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
1051 |
read. |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
1052 |
|
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1053 |
repouri - This is the URL stem that identifies the repo. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1054 |
It's a subset of url. It's also used by the stats system. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1055 |
|
1937
be8995c7bb8f
10924 Want ability to communicate over unix sockets
johansen <johansen@opensolaris.org>
parents:
1895
diff
changeset
|
1056 |
sock_path - Path to a UNIX domain socket. If this option |
be8995c7bb8f
10924 Want ability to communicate over unix sockets
johansen <johansen@opensolaris.org>
parents:
1895
diff
changeset
|
1057 |
is supplied, UNIX sockets will be used instead of TCP sockets. |
be8995c7bb8f
10924 Want ability to communicate over unix sockets
johansen <johansen@opensolaris.org>
parents:
1895
diff
changeset
|
1058 |
|
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1059 |
sslcert - If the request is using SSL, HTTPS for example, |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1060 |
provide a path to the SSL certificate here. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1061 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1062 |
sslkey - If the request is using SSL, liks HTTPS for example, |
1717
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
1063 |
provide a path to the SSL key here. |
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
1064 |
|
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
1065 |
uuid - In order to remove the request from the list of |
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
1066 |
many possible requests, supply a unique identifier in uuid.""" |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1067 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1068 |
self.url = url |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1069 |
self.filepath = filepath |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1070 |
self.writefunc = writefunc |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1071 |
self.hdrfunc = hdrfunc |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1072 |
self.header = header |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1073 |
self.data = data |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1074 |
self.httpmethod = httpmethod |
1472
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1448
diff
changeset
|
1075 |
self.progclass = progclass |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1076 |
self.progtrack = progtrack |
1569
b1d8ed54f455
8584 allow remote search to be canceled via api.cancel
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
1077 |
self.progfunc = progfunc |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1078 |
self.repourl = repourl |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1079 |
self.sslcert = sslcert |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1080 |
self.sslkey = sslkey |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
diff
changeset
|
1081 |
self.compressible = compressible |
1717
bd39c1df2d5c
14240 fileobj must hold transport lock on close
johansen <johansen@sun.com>
parents:
1693
diff
changeset
|
1082 |
self.uuid = uuid |
1937
be8995c7bb8f
10924 Want ability to communicate over unix sockets
johansen <johansen@opensolaris.org>
parents:
1895
diff
changeset
|
1083 |
self.socket_path = sock_path |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
1084 |
self.read_fobj = read_fobj |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1961
diff
changeset
|
1085 |
self.read_filepath = read_filepath |
1991
47ef443bd9b9
16607 depot error response not included in operation failure messages
johansen <johansen@opensolaris.org>
parents:
1974
diff
changeset
|
1086 |
self.failonerror = failonerror |