Commit 25c3b31a authored by jlopez's avatar jlopez
Browse files

Add python support

parent 2dceac02
......@@ -119,6 +119,9 @@ class DBquery
else if($distrib == "Bioconductor" || $distrib == "Conda" || $distrib == "Ruby") {
$package = array($row['name'], $row['version'], $row['description'], $row['doc']);
}
else if($distrib == "Python") {
$package = array($row['name'], $row['version'], $row['description'], $row['doc'], $row['python_depends']);
}
else {
$package = array($row['name'], $row['version'], $row['description'], $row['doc'], $row['rpm']);
}
......
<?php
/**
* Created by PhpStorm.
* User: jimmy
* Date: 26/02/19
* Time: 10:54
*/
require_once "./dao/DBquery.php";
$db = new DBquery();
$distrib = "";
if(isset($_GET['distrib'])) {
$distrib = $_GET['distrib'];
}
$filter = "";
if(isset($_GET['filter'])) {
$filter = $_GET['filter'];
}
if(isset($_GET['filter'])) {
$filter = $_GET['filter'];
}
$patternName = false;
$patternDescription = false;
if(isset($_GET['patternName'])) {
if($_GET['patternName'] == "true") {
$patternName = true;
}
}
if(isset($_GET['patternDescription'])) {
if($_GET['patternDescription'] == "true") {
$patternDescription = true;
}
}
$limit = "25";
if(isset($_GET['limit'])) {
$limit = $_GET['limit'];
}
$result = $db->getPackages($distrib, $filter, $patternName, $patternDescription, $limit);
echo '
<div class="container">
<div class="row justify-content-center">
<h4>Packages found : '.count($result).'</h4>
</div>
</div>
<table id="Table_PackagesPython" class="table table-striped table-bordered">
<thead>
<tr>
<th>Choose</th>
<th>Name</th>
<th>Version</th>
<th>Description</th>
<th>Documentation</th>
<th>Python depends</th>
</tr>
</thead>
<tbody id="TablePackagesPython">
<tr>';
foreach ($result as $t) {
echo '<td><label class="custom-control custom-checkbox">
<input type="checkbox" onclick="generatePackageSelected(this)" data-pname="'.$t[0].'" data-pversion="'.$t[1].'" data-psection="Python" id="checkbox$'.'PackagesPython'.'$'.$t[0].'$'.$t[1].'" class="custom-control-input" name="type">
<span class="custom-control-indicator"></span>
</label></td>';
echo '<td>'.$t[0].'</td>';
echo '<td>'.$t[1].'</td>';
echo '<td>'.$t[2].'</td>';
echo '<td><a href="'.$t[3].'">documentation</a></td>';
echo '<td>'.$t[4].'</td>';
echo '</tr>';
}
echo '</tr>
</tbody>
</table>
';
return $result;
\ No newline at end of file
......@@ -319,7 +319,56 @@ foreach ($db->getSectionParent() as $value){
echo '</div>';
}
else if($s == "Python") {
echo '
<div class="form-group">
<label for="selectedPython" class="font-weight-bold">Python version :</label>
<select class="custom-select" id="selectedPython">
<option value="0" selected="selected">None</option>
<option value="3.7" >3.7</option>
<option value="3.6" >3.6</option>
<option value="3.5" >3.5</option>
<option value="2.7" >2.7</option>
</select>
</div>
<br/>
<label for="findPythonPackages">Find packages with pattern :</label>
<input type="email" class="form-control" id="findPythonPackages">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="patternPythonName" checked>
<label class="form-check-label" for="patternPythonName">Pattern on name</label>
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="patternPythonDescription" checked>
<label class="form-check-label" for="patternPythonDescription">Pattern on description</label>
</div>
<br/>
<div class="form-group">
<label for="limitPython" class="font-check-label">Max found :</label>
<select class="custom-select" id="limitPython">
<option value="5">5</option>
<option value="10" selected="selected">10</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="100">200</option>
<option value="1000000000">all</option>
</select>
</div>
<br/>
<button type="button" class="btn btn-primary" onclick="showPackage(\'Python\')">Search</button>
<br/><br/>
<div id="containPackagesPython">
</div>
';
}
else if($s == "Rubygems") {
echo '
<br/>
......@@ -646,6 +695,8 @@ foreach ($db->getSectionParent() as $value){
var rversion = document.getElementById("selectedR").value;
var pythonversion = document.getElementById("selectedPython").value;
var nrow = 2;
//HEADER
......@@ -873,6 +924,58 @@ foreach ($db->getSectionParent() as $value){
}
}
if(SELECTED_PACKAGES["Python"].length > 0) {
PREVIEW += "\n\n############### Install Python ##############\n";
if(isSingularity) {
PREVIEW += "\t"+manager+" install -y " + "python" + pythonversion + "\n";
} else {
PREVIEW += "RUN "+manager+" install -y " + "python" + pythonversion + "\n";
}
if(pythonversion == "2.7") {
if(isSingularity) {
PREVIEW += "\t"+manager+" install -y " + "python-pip" + "\n";
} else {
PREVIEW += "RUN "+manager+" install -y " + "python-pip" + "\n";
}
} else {
if(isSingularity) {
PREVIEW += "\t"+manager+" install -y " + "python3-pip" + "\n";
} else {
PREVIEW += "RUN "+manager+" install -y " + "python3-pip" + "\n";
}
}
if(isSingularity) {
PREVIEW += "\t"+" pip install --upgrade pip" + "\n";
} else {
PREVIEW += "RUN "+" pip install --upgrade pip" + "\n";
}
nrow += 3;
for(var i = 0; i < SELECTED_PACKAGES["Python"].length; i++) {
if(isSingularity) {
PREVIEW += "\n\tpip install "+SELECTED_PACKAGES["Python"][i][0] + "==" + SELECTED_PACKAGES["Python"][i][1];
} else {
PREVIEW += "\nRUN pip install "+SELECTED_PACKAGES["Python"][i][0] + "==" + SELECTED_PACKAGES["Python"][i][1];
}
nrow += 1;
}
}
if(SELECTED_PACKAGES["CPAN"].length > 0) {
......@@ -943,7 +1046,11 @@ foreach ($db->getSectionParent() as $value){
if((SELECTED_PACKAGES["CRAN"].length > 0 || SELECTED_PACKAGES["Bioconductor"].length > 0 ) && document.getElementById("selectedR").value == 0) {
alert("Please choose R version");
} else {
}
else if(SELECTED_PACKAGES["Python"].length > 0 && document.getElementById("selectedPython").value == 0) {
alert("Please choose Python version");
}
else {
var preview = generate_container();
$("#containerPreview").text(PREVIEW);
}
......
from xmlrpclib import ServerProxy
import re
from os import walk
import os
import sys
from bs4 import BeautifulSoup
from rpmUtils.miscutils import splitFilename
URL = 'https://pypi.python.org/pypi'
TEST = '0*'
import urllib, json
def main():
reload(sys)
sys.setdefaultencoding('utf8')
pypi = ServerProxy(URL)
URL_INFO = 'https://pypi.python.org/pypi/'
URL_SIMPLE = "https://pypi.org/simple/"
def run():
try:
import xmlrpclib
except ImportError:
import xmlrpc.client as xmlrpclib
client = xmlrpclib.ServerProxy('https://pypi.python.org/pypi')
# get a list of package names
packages = client.list_packages()
indexP = 0
print("Start : python")
results = open("./python/packages.csv","w")
for p in packages:
print(p)
response = urllib.urlopen(URL_INFO+p+"/json")
if response.getcode() == 404 :
print(" 404 : " + p)
continue
dataP = json.loads(response.read())
res = pypi.search({'name': TEST})
name = p
version = dataP['info']['version']
description = dataP['info']['summary']
doc = dataP['info']['home_page']
print(res)
if(doc == None):
doc = ""
for r in res:
m = re.match("0*", r['name'])
if m:
#print(m.group(0))
print(r)
classifiers = dataP['info']['classifiers']
depends_python = ""
for c in classifiers:
if("Programming Language" in c):
#print(c)
val1 = c.replace('Programming Language :: Python','')
if val1 != "":
val2 = val1.replace(' :: ', '')
depends_python = depends_python + val2 + ' | '
if(depends_python == ""):
depends_python = "all"
if(version == None):
version = "0"
if(description == None):
description = ""
if(doc == None):
doc = ""
line = '"' + name + '";"' + version + '";"' + description + '";"' + doc + '";"' + depends_python + '"\n'
line = line.encode('utf-8')
results.write(line)
indexP = indexP + 1
print(str(indexP) + " / " + str(len(packages)))
print("Packages : " + str(indexP))
print("End : python")
if __name__ == '__main__':
main()
run()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment