[123303] branches/gsoc14-pip2port
gaurav at macports.org
gaurav at macports.org
Thu Aug 7 16:28:58 PDT 2014
Revision: 123303
https://trac.macports.org/changeset/123303
Author: gaurav at macports.org
Date: 2014-08-07 16:28:58 -0700 (Thu, 07 Aug 2014)
Log Message:
-----------
Updated 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 23:28:07 UTC (rev 123302)
+++ branches/gsoc14-pip2port/pypi2port 2014-08-07 23:28:58 UTC (rev 123303)
@@ -25,6 +25,8 @@
import difflib
import subprocess
import requests
+import shlex
+import getpass
client = xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
@@ -250,125 +252,149 @@
match = re.search(patterns[i],license)
if match:
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']))
Modified: branches/gsoc14-pip2port/pypi2port.py
===================================================================
--- branches/gsoc14-pip2port/pypi2port.py 2014-08-07 23:28:07 UTC (rev 123302)
+++ branches/gsoc14-pip2port/pypi2port.py 2014-08-07 23:28:58 UTC (rev 123303)
@@ -288,7 +288,7 @@
if euid:
args = ['sudo',sys.executable] + sys.argv + [os.environ]
os.execlpe('sudo',*args)
-# print port_fetch(name,portv,"verbose")
+# print port_fetch(name,portv)
@@ -298,7 +298,7 @@
# 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()
+# 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:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140807/7d490b6c/attachment-0001.html>
More information about the macports-changes
mailing list