Shawn, Saurabh,
Thanks for reviewing the code.
Please see my comments in-lined.

On 10/19/12 02:01, Shawn Walker wrote:
On 10/16/12 23:49, Thejaswini wrote:
Hi All,

Please review the fixes for the below CR's:

1. 7197510: pkgrecv error handling traces back:
http://monaco.us.oracle.com/detail.jsf?cr=7197510

2. 7197865: pkgrecv dies with ENOSPC:
http://monaco.us.oracle.com/detail.jsf?cr=7197865

Webrev @:
https://cr.opensolaris.org/action/browse/pkg/tk241774/7197510/webrev/

src/modules/misc.py:
  line 68: s/would/will/

  line 1067: drop this extra newline

    line 1068: drop the leading whitespace in the docstring

  line 1069: s/would have been/should be/

  line 1071: missing '.'
Done.


src/pull.py:
  line 950: why this change?  the indentation isn't right
Already done as mentioned by Saurabh.

I've also updated the bug synopsis for 7197865 as it wasn't very clear, so please update your changeset comment as well.
Done.

Below if the webrev with the changes.
https://cr.opensolaris.org/action/browse/pkg/tk241774/7197510-rev2/webrev/

Also make packages is clean.
If the changes look good, could you or anyone push this?
Please find the patch attached.

Thanks,
Thejaswini K.


Thanks,
-Shawn
# HG changeset patch
# User [email protected]
# Date 1350622756 -19800
# Node ID eafd7a0a64bb97ac6b627f858329ec3605ae77fd
# Parent  17425ca1f195cfd0615b4b5aef7b3d2febeedafc
7197510 pkgrecv error handling traces back
7197865 pkgrecv doesn't cleanup temporary files when failing due to space errors

diff -r 17425ca1f195 -r eafd7a0a64bb src/modules/misc.py
--- a/src/modules/misc.py       Wed Oct 17 13:37:11 2012 -0700
+++ b/src/modules/misc.py       Fri Oct 19 10:29:16 2012 +0530
@@ -65,6 +65,9 @@
 from pkg.client.imagetypes import img_type_names, IMG_NONE
 from pkg.pkggzip import PkgGzipFile
 
+# Default path where the temporary directories will be created.
+DEFAULT_TEMP_PATH = "/var/tmp"
+
 # Minimum number of days to issue warning before a certificate expires
 MIN_WARN_DAYS = datetime.timedelta(days=30)
 
@@ -1048,8 +1051,6 @@
         settings when creating temporary files/directories.  Otherwise,
         return a path that the caller should pass to tempfile instead."""
 
-        default_root = "/var/tmp"
-
         # In Python's tempfile module, the default temp directory
         # includes some paths that are suboptimal for holding large numbers
         # of files.  If the user hasn't set TMPDIR, TEMP, or TMP in the
@@ -1060,7 +1061,21 @@
                 if env_val:
                         return None
 
-        return default_root
+        return DEFAULT_TEMP_PATH
+
+def get_temp_root_path():
+        """Return the directory path where the temporary directories or 
+        files should be created. If the environment has set TMPDIR
+        or TEMP or TMP then return the corresponding value else return the
+        default value."""
+
+        temp_env = [ "TMPDIR", "TEMP", "TMP" ]
+        for env in temp_env:
+                env_val = os.getenv(env)
+                if env_val:
+                        return env_val
+
+        return DEFAULT_TEMP_PATH 
 
 def parse_uri(uri, cwd=None):
         """Parse the repository location provided and attempt to transform it
diff -r 17425ca1f195 -r eafd7a0a64bb src/pull.py
--- a/src/pull.py       Wed Oct 17 13:37:11 2012 -0700
+++ b/src/pull.py       Fri Oct 19 10:29:16 2012 +0530
@@ -989,7 +989,8 @@
                 else:
                         txt += _("No storage space left.")
 
-                tdirs = [temp_root]
+                temp_root_path = misc.get_temp_root_path()
+                tdirs = [temp_root_path]
                 if cache_dir not in tmpdirs:
                         # Only include in message if user specified.
                         tdirs.append(cache_dir)
@@ -1000,7 +1001,12 @@
                 error(txt + _("Please verify that the filesystem containing "
                    "the following directories has enough space available:\n"
                    "%s") % "\n".join(tdirs))
-                __ret = 1
+                try:
+                        cleanup()
+                except:
+                        __ret = 99
+                else:
+                        __ret = 1
         except:
                 traceback.print_exc()
                 error(misc.get_traceback_message())
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss

Reply via email to