コード例 #1
0
ファイル: __init__.py プロジェクト: SMFOSS/cheese_emporium
def upload():
    f = request.files["content"]
    f.save(os.path.join(app.config["FILE_ROOT"], secure_filename(f.filename)))
    regenerate_index(app.config["FILE_ROOT"], "index.html")
    response = make_response()
    response.headers["X-Swalow-Status"] = "SUCCESS"
    return response
コード例 #2
0
ファイル: __init__.py プロジェクト: binarydud/cheese_emporium
def from_requirements():
    if request.method == "POST":
        f = request.files['req_file']
        
        filename = os.path.join(tempfile.gettempdir(),'temp-req.txt')
        f.save(filename)
        try:
            names = parse_reqs(filename, app.config['FILE_ROOT'])
        except:
            flash('There were some errors getting files from the uploaded requirements')
        else:
            flash('packages were installed from the requirements file. %s' % names)
        finally:
            regenerate_index(app.config['FILE_ROOT'],'index.html')
        
        return redirect('/requirements')
    return render_template('requirements_upload.html')
コード例 #3
0
ファイル: __init__.py プロジェクト: SMFOSS/cheese_emporium
def from_requirements():
    if request.method == "POST":
        f = request.files["req_file"]

        filename = os.path.join(tempfile.gettempdir(), "temp-req.txt")
        f.save(filename)
        try:
            names = parse_reqs(filename, app.config["FILE_ROOT"])
        except:
            flash("There were some errors getting files from the uploaded requirements")
        else:
            flash("packages were installed from the requirements file. %s" % names)
        finally:
            regenerate_index(app.config["FILE_ROOT"], "index.html")

        return redirect("/requirements")
    return render_template("requirements_upload.html")
コード例 #4
0
ファイル: test_index.py プロジェクト: SMFOSS/cheese_emporium
from utils import regenerate_index
from cheese_emporium import FILE_ROOT

if __name__ == "__main__":
    regenerate_index(FILE_ROOT, 'index.html')
コード例 #5
0
ファイル: __init__.py プロジェクト: binarydud/cheese_emporium
def regenerate():
    if request.method == 'POST':
        regenerate_index(app.config['FILE_ROOT'],'index.html')
        flash('Index has been regenerated.')
        return redirect('/')
    return render_template('regenerate.html')
コード例 #6
0
ファイル: __init__.py プロジェクト: binarydud/cheese_emporium
            req = Request(url)
            f = urlopen(req)
            print "downloading " + url

        	# Open our local file for writing
            local_file = open(os.path.join(app.config['FILE_ROOT'],filename), "w")
            #Write to our local file
            local_file.write(f.read())
            local_file.close()
            print 'finished downloading'
        #handle errors
        except HTTPError, e:
            print "HTTP Error:", e.code , url
        except URLError, e:
            print "URL Error:", e.reason , url
        regenerate_index(app.config['FILE_ROOT'],'index.html')
        flash('%s-%s was installed into the index successfully.' % (name, version))
    return redirect('/')


@app.route('/regenerate-index',methods=['POST', 'GET'])
def regenerate():
    if request.method == 'POST':
        regenerate_index(app.config['FILE_ROOT'],'index.html')
        flash('Index has been regenerated.')
        return redirect('/')
    return render_template('regenerate.html')


@app.route('/requirements',methods=['POST','GET'])
def from_requirements():
コード例 #7
0
ファイル: __init__.py プロジェクト: SMFOSS/cheese_emporium
def regenerate():
    if request.method == "POST":
        regenerate_index(app.config["FILE_ROOT"], "index.html")
        return redirect("/index")
    return render_template("regenerate.html")
コード例 #8
0
ファイル: __init__.py プロジェクト: SMFOSS/cheese_emporium
            req = Request(url)
            f = urlopen(req)
            print "downloading " + url

            # Open our local file for writing
            local_file = open(os.path.join(app.config["FILE_ROOT"], filename), "w")
            # Write to our local file
            local_file.write(f.read())
            local_file.close()
            print "finished downloading"
        # handle errors
        except HTTPError, e:
            print "HTTP Error:", e.code, url
        except URLError, e:
            print "URL Error:", e.reason, url
        regenerate_index(app.config["FILE_ROOT"], "index.html")
        flash("%s-%s was installed into the index successfully." % (name, version))
    return redirect("/")


@app.route("/regenerate-index", methods=["POST", "GET"])
def regenerate():
    if request.method == "POST":
        regenerate_index(app.config["FILE_ROOT"], "index.html")
        return redirect("/index")
    return render_template("regenerate.html")


@app.route("/requirements", methods=["POST", "GET"])
def from_requirements():
    if request.method == "POST":