#12018: sage-list-packages will fail if user can't write to SAGE_ROOT
--------------------------+-------------------------------------------------
   Reporter:  jhpalmieri  |          Owner:  leif         
       Type:  defect      |         Status:  needs_review 
   Priority:  minor       |      Milestone:  sage-5.0     
  Component:  scripts     |       Keywords:               
Work_issues:              |       Upstream:  N/A          
   Reviewer:              |         Author:  John Palmieri
     Merged:              |   Dependencies:               
--------------------------+-------------------------------------------------

Comment(by jhpalmieri):

 I'm happy to use your approach and not to create a file.  Some more
 comments: I think using urlparse.urljoin will clean some things up:
 {{{
 #!diff
 diff --git a/sage-list-packages b/sage-list-packages
 --- a/sage-list-packages
 +++ b/sage-list-packages
 @@ -11,16 +11,11 @@ if not os.environ.has_key("SAGE_SERVER")
       print "The environment variable SAGE_SERVER must be set"
       sys.exit(1)

 -url_list = list(urlparse.urlsplit(os.environ['SAGE_SERVER']))
 -url_path = os.path.join(url_list[2], 'packages')
 -url_list[2] = urllib.pathname2url(url_path)
 -
 -PKG_SERVER = urlparse.urlunsplit(url_list)
 +PKG_SERVER = urlparse.urljoin(os.environ['SAGE_SERVER'], 'packages')
  print "Using SAGE Server %s"%PKG_SERVER

 -url_path = os.path.join(url_path, sys.argv[1], 'list')
 -url_list[2] = urllib.pathname2url(url_path)
 -url = urlparse.urlunsplit(url_list)
 +url_path = os.path.join('packages', sys.argv[1], 'list')
 +url = urlparse.urljoin(PKG_SERVER, urllib.pathname2url(url_path))

  try:
       installed = set(os.listdir(os.path.join(SPKG_ROOT, 'installed')))
 }}}
 Also, according to the
 [http://docs.python.org/library/urllib.html#urllib.urlopen Python
 documentation], urllib.urlopen is deprecated in favor of urllib2.urlopen.
 Maybe we should use that instead?

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12018#comment:7>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to