author | Shawn Walker <srw@sun.com> |
Wed, 02 Dec 2009 22:07:06 -0600 | |
changeset 1538 | 78ac66abc186 |
parent 1537 | 00a5b4d54eb8 |
child 1573 | ae7488fbff6a |
permissions | -rw-r--r-- |
1516
8c950a3b4171
10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents:
1505
diff
changeset
|
1 |
#!/usr/bin/python |
1336
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
2 |
# |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
4 |
# |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
8 |
# |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
13 |
# |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
19 |
# |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
21 |
# |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
22 |
# Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
23 |
# Use is subject to license terms. |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
24 |
# |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
25 |
|
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
26 |
import os |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
27 |
import cPickle |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
28 |
|
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
29 |
import pkg.client.api as api |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
30 |
from pkg.client import global_settings |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
31 |
|
1537 | 32 |
# The current version of the Client API the PM, UM and |
33 |
# WebInstall GUIs have been tested against and are known to work with. |
|
1538
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
34 |
CLIENT_API_VERSION = 26 |
1336
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
35 |
|
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
36 |
def get_cache_dir(api_object): |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
37 |
img = api_object.img |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
38 |
cache_dir = os.path.join(img.imgdir, "gui_cache") |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
39 |
try: |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
40 |
__mkdir(cache_dir) |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
41 |
except OSError: |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
42 |
cache_dir = None |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
43 |
return cache_dir |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
44 |
|
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
45 |
def __mkdir(directory_path): |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
46 |
if not os.path.isdir(directory_path): |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
47 |
os.makedirs(directory_path) |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
48 |
|
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
49 |
def get_api_object(img_dir, progtrack): |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
50 |
api_o = None |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
51 |
api_o = api.ImageInterface(img_dir, |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
52 |
CLIENT_API_VERSION, |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
53 |
progtrack, None, global_settings.client_name) |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
54 |
return api_o |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
55 |
|
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
56 |
def read_cache_file(file_path): |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
57 |
fh = open(file_path, 'r') |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
58 |
data = cPickle.load(fh) |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
59 |
fh.close() |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
60 |
return data |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
61 |
|
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
62 |
def dump_cache_file(file_path, data): |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
63 |
fh = open(file_path,"w") |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
64 |
cPickle.dump(data, fh, True) |
2ea22dad29e3
10192 /usr/lib/pm-checkforupdates emits warning when DISPLAY is not set.
Padraig O'Briain <padraig.obriain@sun.com>
parents:
diff
changeset
|
65 |
fh.close() |