[123216] branches/gsoc14-pip2port/pypi2port.py
gaurav at macports.org
gaurav at macports.org
Wed Aug 6 19:40:41 PDT 2014
Revision: 123216
https://trac.macports.org/changeset/123216
Author: gaurav at macports.org
Date: 2014-08-06 19:40:41 -0700 (Wed, 06 Aug 2014)
Log Message:
-----------
Added a testing option
Modified Paths:
--------------
branches/gsoc14-pip2port/pypi2port.py
Modified: branches/gsoc14-pip2port/pypi2port.py
===================================================================
--- branches/gsoc14-pip2port/pypi2port.py 2014-08-07 02:33:03 UTC (rev 123215)
+++ branches/gsoc14-pip2port/pypi2port.py 2014-08-07 02:40:41 UTC (rev 123216)
@@ -252,103 +252,125 @@
return licenses[i]
-#def testing(name,portv=27,type="quiet"):
-
+def port_testing(name,portv='27',type="quiet"):
+ euid = os.geteuid()
+# print euid
+ if not euid:
+ args = ['sudo',sys.executable] + sys.argv + [os.environ]
+ os.execlpe('sudo',*args)
+ 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)
+ if not phase_output:
+ print phase.__name__+" FAILED"
+ print "Exiting"
+ break
+ else:
+ print phase.__name__+" - SUCCESS"
+ euid = os.geteuid()
+ if not 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',type="quiet"):
+# print name,portv,type
+# print command
try:
- command = "sudo port -t fetch dports/python/py-"+name+" subport=py"+portv+"-"name
- if type=="quiet":
+ 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()
return phase_output
- except Exception e:
+ except:
return False
-def port_checksum(name,portv=27,type="quiet"):
+def port_checksum(name,portv='27',type="quiet"):
try:
- command = "sudo port -t checksum dports/python/py-"+name+" subport=py"+portv+"-"name
+ 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()
return phase_output
- except Exception e:
+ except:
return False
-def port_extract(name,portv=27,type="quiet"):
+def port_extract(name,portv='27',type="quiet"):
try:
- command = "sudo port -t extract dports/python/py-"+name+" subport=py"+portv+"-"name
+ 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()
return phase_output
- except Exception e:
+ except:
return False
-def port_patch(name,portv=27,type="quiet"):
+def port_patch(name,portv='27',type="quiet"):
try:
- command = "sudo port -t patch dports/python/py-"+name+" subport=py"+portv+"-"name
+ 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()
return phase_output
- except Exception e:
+ except:
return False
-def port_configure(name,portv=27,type="quiet"):
+def port_configure(name,portv='27',type="quiet"):
try:
- command = "sudo port -t configure dports/python/py-"+name+" subport=py"+portv+"-"name
+ 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()
return phase_output
- except Exception e:
+ except:
return False
-def port_build(name,portv=27,type="quiet"):
+def port_build(name,portv='27',type="quiet"):
try:
- command = "sudo port -t build dports/python/py-"+name+" subport=py"+portv+"-"name
+ 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()
return phase_output
- except Exception e:
+ except:
return False
-def port_destroot(name,portv=27,type="quiet"):
+def port_destroot(name,portv='27',type="quiet"):
try:
- command = "sudo port -t destroot dports/python/py-"+name+" subport=py"+portv+"-"name
+ 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()
return phase_output
- except Exception e:
+ except:
return False
-def port_clean(name,portv=27,type="quiet"):
+def port_clean(name,portv='27',type="quiet"):
try:
- command = "sudo port -t clean dports/python/py-"+name+" subport=py"+portv+"-"name
+ 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()
return phase_output
- except Exception e:
+ except:
return False
@@ -564,6 +586,9 @@
parser.add_argument('-p', '--portfile', action='store', type=str,
dest='package_portfile', nargs='*', required=False,
help='Prints the portfile for a package')
+ parser.add_argument('-t', '--test', action='store', type=str,
+ dest='package_test', nargs='*', required=False,
+ help='Tests the portfile for a package for various phase tests')
options = parser.parse_args()
if options.list:
@@ -616,6 +641,14 @@
print "No release found\n"
return
+ if options.package_test:
+ if len(options.package_test) > 0:
+ pkg_name = options.package_test[0]
+ port_testing(pkg_name)
+ else:
+ print "No package name specified\n"
+ return
+
parser.print_help()
parser.error("No input specified")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140806/6cd7896b/attachment-0001.html>
More information about the macports-changes
mailing list