コード例 #1
0
ファイル: resync.py プロジェクト: jbiss1/PyRPM2HTML_MySQL
def registerDist(path, name, html, color,  ftp, ftpsrc, subdir, localmirror):
    global nb_distribs

    nb_distribs = nb_distribs + 1
    if sql.do_sql_query("SELECT ID from Distribs where Directory='%s'" % (path)) < 0:
        return -1
    list = sql.cursor.fetchone()
    if list == None:
        print("Found new dist %s at %s" % (name, path))

    id = int(sql.sql_get_key('Distribs', 'Directory', path))
    if name != None and name != '':
        sql.sql_update_id("Distribs", id, "Name", name)
    if subdir != None and subdir != '':
        sql.sql_update_id("Distribs", id, "Path", subdir)
    if ftp != None and ftp != '':
        sql.sql_update_id("Distribs", id, "URL", ftp)
    if ftpsrc != None and ftpsrc != '':
        sql.sql_update_id("Distribs", id, "URLSrc", ftpsrc)
    if html != None and html != '':
        sql.sql_update_id("Distribs", id, "Html", html)
    if color != None and color != '':
        sql.sql_update_id("Distribs", id, "Color", color)
    if localmirror != None and localmirror != "":
        try:
            sql.cursor.execute("INSERT INTO Mirrors (ID,URL) VALUES (%s,'%s')" % (id, localmirror))
        except:
            pass
コード例 #2
0
ファイル: resync.py プロジェクト: jbiss1/PyRPM2HTML_MySQL
def sync_mirrors():
    if sql.do_sql_query("SELECT name, URL from Searches") < 0:
        return -1
    list = sql.cursor.fetchone()
    lists = []
    # store in lists because sync_mirror destroys the sql.cursor.
    while list != None:
        name = list[0]
	if name == 'fr2':
	    list = sql.cursor.fetchone()
	    continue
	URL = list[1]
	if hostname == 'rpmfind.net':
	    if name != 'rpmfind':
	        lists.append((name, URL))
	elif hostname == 'speakeasy.rpmfind.net':
	    if name != 'speakeasy':
	        lists.append((name, URL))
	elif hostname == 'fr.rpmfind.net':
	    if name != 'fr':
	        lists.append((name, URL))
	list = sql.cursor.fetchone()
    for list in lists:
        name = list[0]
	URL = list[1]
	sync_mirror(name, URL);
コード例 #3
0
ファイル: resync.py プロジェクト: jbiss1/PyRPM2HTML_MySQL
def dump_local_config():
    conf = open("rpm2html-local.config", "w")
    conf.write(""";
; Configuration file for rpm2html-1.0
;  See http://www.nongnu.org/rpm2html/
;
; Generated from the database by resync.py
;
; maintainer of the local rpm mirror
maint=Daniel Veillard
; mail for the maintainer
[email protected]
; Directory to store the HTML pages produced
dir=/serveur/ftp/linux/RPM
; The relative URL for front pages
url=/linux/RPM
; Export the local packages in HTML format
html=true
; Export the local packages in RDF format
rdf=false
rdf_dir=
; Protect e-mails from SPAM bots by mangling them in HTML output
protectemails=true
; Compile a list of resources in RDF format
rdf_resources=false
rdf_resources_dir=
; Extra headers in generated pages
header=http://rpmfind.net/linux/rpm2html/mirrors.html Mirrors
header=http://rpmfind.net/linux/rpm2html/help.html Help
header=http://rpmfind.net/linux/rpm2html/search.php Search
; Build the tree for the distributions
tree=true
;
; Configuration for an RPM directory
;
; [The name between brackets is the directory, NEEDED !]
; name=A significant name for this mirror, NEEDED !
; ftp=The original FTP/HTTP url, NEEDED !
; ftpsrc=Where the associated sources are stored
; subdir=subdirectory for generated pages
; color=Background color for pages
; url= relative URL for pages in this directory
; URL can be defined for mirrors the first one is the 'local' one
;
""")
    if sql.do_sql_query("SELECT ID,Name, Directory, Path, URL, URLSrc, Html, Color from Distribs") < 0:
        return -1
    distribs = {}
    list = sql.cursor.fetchone()
    while list != None:
        try:
	    (ID,Name,Directory,Path,URL,URLSrc,Html,Color) = list
	    os.stat(Directory)
	    ID=int(ID)
	except:
	    list = sql.cursor.fetchone()
	    continue
	if Name != None and Name != "" and Path != None and Path != "" and \
	    URL != None and URL != "":
	    distribs[ID] = [list, ()];
	list = sql.cursor.fetchone()

    for ID in list(distribs.keys()):
        if sql.do_sql_query("SELECT URL from Mirrors where ID=%s" % ID) < 0:
	    continue
	mirrors = sql.cursor.fetchall()
	distribs[ID][1] = mirrors
	
    for ID in list(distribs.keys()):
        list = distribs[ID][0];
	(id,Name,Directory,Path,URL,URLSrc,Html,Color) = list
        mirrors = distribs[ID][1];

	conf.write("[%s]\n"% Directory)
	conf.write("name=%s\n"% Name)
	if Html != None and Html != "":
	    conf.write("html=%s\n"% Html)
	conf.write("ftp=%s\n"% URL);
	if URLSrc != None and URLSrc != "":
	    conf.write("ftpsrc=%s\n"% URLSrc)
	conf.write("subdir=%s\n"% Path);
	if Color != None and Color != "":
	    conf.write("color=%s\n"% Color)
	for mirror in mirrors:
	    conf.write("mirror=%s\n"% mirror)
	conf.write("\n")
    
    conf.close()
    print("Dumped %d distrib info to rpm2html-local.config\n" % (
          len(list(distribs.keys()))))