[123218] branches/gsoc14-pip2port

gaurav at macports.org gaurav at macports.org
Wed Aug 6 20:27:17 PDT 2014


Revision: 123218
          https://trac.macports.org/changeset/123218
Author:   gaurav at macports.org
Date:     2014-08-06 20:27:17 -0700 (Wed, 06 Aug 2014)
Log Message:
-----------
Updated the testing function

Modified Paths:
--------------
    branches/gsoc14-pip2port/pypi2port
    branches/gsoc14-pip2port/pypi2port.py

Modified: branches/gsoc14-pip2port/pypi2port
===================================================================
--- branches/gsoc14-pip2port/pypi2port	2014-08-07 02:41:15 UTC (rev 123217)
+++ branches/gsoc14-pip2port/pypi2port	2014-08-07 03:27:17 UTC (rev 123218)
@@ -250,8 +250,8 @@
         match = re.search(patterns[i],license)
         if match:
             return licenses[i]
-    
 
+
 def port_testing(name,portv='27',type="quiet"):
     euid = os.geteuid()
 #    print euid
@@ -272,9 +272,9 @@
             args = ['sudo',sys.executable] + sys.argv + [os.environ]
             os.execlpe('sudo',*args)
 #    print port_fetch(name,portv,"verbose")
-        
 
 
+
 def port_fetch(name,portv='27',type="quiet"):
 #    print name,portv,type
 #    print command

Modified: branches/gsoc14-pip2port/pypi2port.py
===================================================================
--- branches/gsoc14-pip2port/pypi2port.py	2014-08-07 02:41:15 UTC (rev 123217)
+++ branches/gsoc14-pip2port/pypi2port.py	2014-08-07 03:27:17 UTC (rev 123218)
@@ -25,6 +25,8 @@
 import difflib
 import subprocess
 import requests
+import shlex
+import getpass
 
 client = xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
 
@@ -252,123 +254,147 @@
             return licenses[i]
     
 
-def port_testing(name,portv='27',type="quiet"):
+def port_testing(name,portv='27'):
     euid = os.geteuid()
 #    print euid
-    if not euid:
+    if euid:
         args = ['sudo',sys.executable] + sys.argv + [os.environ]
         os.execlpe('sudo',*args)
+
+#    if os.getuid():
+#        raise Exception("This program is not run as sudo or elevated this it will not work")
+#        print "This program is not run as sudo or elevated, thus It will not work"
+#        sys.exit(0)
+#    print "This script was called by: "+getpass.getuser()
+#    print "Now do something as 'root'..."
+#    subprocess.call(shlex.split('sudo id -nu'))
     for phase in [port_fetch,port_checksum,port_extract,port_configure,port_build,port_destroot,port_clean]:
-#        print phase.__name__
-        phase_output = phase(name,portv,type)
+        print phase.__name__
+        phase_output = phase(name,portv)
         if not phase_output:
             print phase.__name__+" FAILED"
             print "Exiting"
             break
         else:
             print phase.__name__+" - SUCCESS"
+
+#    print "Now swtiching back to the calling user: "+getpass.getuser()
+
+#        if os.getuid():
+#            print "This program is not run as sudo or elevated, thus It will not work"
+#            sys.exit(0)
+
         euid = os.geteuid()
-        if not euid:
+        if euid:
             args = ['sudo',sys.executable] + sys.argv + [os.environ]
             os.execlpe('sudo',*args)
 #    print port_fetch(name,portv,"verbose")
         
 
 
-def port_fetch(name,portv='27',type="quiet"):
+def port_fetch(name,portv='27'):
 #    print name,portv,type
+#    command = "sudo port -t fetch dports/python/py-"+name+" subport=py"+portv+"-"+name
 #    print command
     try:
         command = "sudo port -t fetch dports/python/py-"+name+" subport=py"+portv+"-"+name
-#        phase_output = subprocess.call(command,shell=True,stderr=subprocess.STDOUT).strip()
-        if type == "quiet":
-            phase_output = subprocess.check_output(command,shell=True,stderr=subprocess.STDOUT).strip()
-        else:
-            phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()            
+        phase_output = subprocess.call(command,shell=True,stderr=subprocess.STDOUT).strip()
+#        if type == "quiet":
+#            phase_output = subprocess.check_output(command,shell=True,stderr=subprocess.STDOUT).strip()
+#        else:
+#            phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()
+        phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()
         return phase_output
     except:
         return False
 
 
-def port_checksum(name,portv='27',type="quiet"):
+def port_checksum(name,portv='27'):
     try:
         command = "sudo port -t checksum dports/python/py-"+name+" subport=py"+portv+"-"+name
-        if type=="quiet":
-            phase_output = subprocess.check_output(command,shell=True,stderr=subprocess.STDOUT).strip()
-        else:
-            phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()            
+#        if type=="quiet":
+#            phase_output = subprocess.check_output(command,shell=True,stderr=subprocess.STDOUT).strip()
+#        else:
+#            phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()            
+        phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()
         return phase_output
     except:
         return False
 
 
-def port_extract(name,portv='27',type="quiet"):
+def port_extract(name,portv='27'):
     try:
         command = "sudo port -t extract dports/python/py-"+name+" subport=py"+portv+"-"+name
-        if type=="quiet":
-            phase_output = subprocess.check_output(command,shell=True,stderr=subprocess.STDOUT).strip()
-        else:
-            phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()            
+#        if type=="quiet":
+#            phase_output = subprocess.check_output(command,shell=True,stderr=subprocess.STDOUT).strip()
+#        else:
+#            phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()            
+        phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()
         return phase_output
     except:
         return False
 
 
-def port_patch(name,portv='27',type="quiet"):
+def port_patch(name,portv='27'):
     try:
         command = "sudo port -t patch dports/python/py-"+name+" subport=py"+portv+"-"+name
-        if type=="quiet":
-            phase_output = subprocess.check_output(command,shell=True,stderr=subprocess.STDOUT).strip()
-        else:
-            phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()            
+#        if type=="quiet":
+#            phase_output = subprocess.check_output(command,shell=True,stderr=subprocess.STDOUT).strip()
+#        else:
+#            phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()            
+        phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()
         return phase_output
     except:
         return False
 
 
-def port_configure(name,portv='27',type="quiet"):
+def port_configure(name,portv='27'):
     try:
         command = "sudo port -t configure dports/python/py-"+name+" subport=py"+portv+"-"+name
-        if type=="quiet":
-            phase_output = subprocess.check_output(command,shell=True,stderr=subprocess.STDOUT).strip()
-        else:
-            phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()            
+#        if type=="quiet":
+#            phase_output = subprocess.check_output(command,shell=True,stderr=subprocess.STDOUT).strip()
+#        else:
+#            phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()            
+        phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()
         return phase_output
     except:
         return False
 
 
-def port_build(name,portv='27',type="quiet"):
+def port_build(name,portv='27'):
     try:
         command = "sudo port -t build dports/python/py-"+name+" subport=py"+portv+"-"+name
-        if type=="quiet":
-            phase_output = subprocess.check_output(command,shell=True,stderr=subprocess.STDOUT).strip()
-        else:
-            phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()            
+#        if type=="quiet":
+#            phase_output = subprocess.check_output(command,shell=True,stderr=subprocess.STDOUT).strip()
+#        else:
+#            phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()            
+        phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()
         return phase_output
     except:
         return False
 
 
-def port_destroot(name,portv='27',type="quiet"):
+def port_destroot(name,portv='27'):
     try:
         command = "sudo port -t destroot dports/python/py-"+name+" subport=py"+portv+"-"+name
-        if type=="quiet":
-            phase_output = subprocess.check_output(command,shell=True,stderr=subprocess.STDOUT).strip()
-        else:
-            phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()            
+#        if type=="quiet":
+#            phase_output = subprocess.check_output(command,shell=True,stderr=subprocess.STDOUT).strip()
+#        else:
+#            phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()            
+        phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()
         return phase_output
     except:
         return False
 	
 
-def port_clean(name,portv='27',type="quiet"):
+def port_clean(name,portv='27'):
     try:
         command = "sudo port -t clean dports/python/py-"+name+" subport=py"+portv+"-"+name
-        if type=="quiet":
-            phase_output = subprocess.check_output(command,shell=True,stderr=subprocess.STDOUT).strip()
-        else:
-            phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()            
+#        if type=="quiet":
+#            phase_output = subprocess.check_output(command,shell=True,stderr=subprocess.STDOUT).strip()
+#        else:
+#            phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()            
+        phase_output = subprocess.check_call(command,shell=True,stderr=subprocess.STDOUT).strip()
         return phase_output
     except:
         return False
@@ -487,7 +513,7 @@
             master_site_exists = True
         else:
             master_site_exists = False
-        file.write('distname            {0}-{1}.tar.gz\n\n'.format(
+        file.write('distname            {0}-{1}\n\n'.format(
                    dict['name'], dict['version']))
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140806/38f4582e/attachment-0001.html>


More information about the macports-changes mailing list