def serve(request):

    p = Playlist()
    player = Player()

    doc = CGI.httpHeaders()
    doc += CGI.htmlHead({ 'style':['../playlist.css'] })

    if request.command == "POST":
        form = request.form
        if form.has_key('addSongs'):
            for e in makeList(form.getvalue('song')):
                if e is not None:
                    doc += addSong(p, e)
        elif form.has_key('addAlbums'):
            for e in makeList(form.getvalue('album')):
                if e is not None:
                    doc += addAlbum(p, e)
        elif form.has_key('clear'):
            p.clear()
        elif form.has_key('clearAndStop'):
            p.clear()
            request.state.stop()
            player.stop()

    f = p.update()
    doc += playlistToHtml(f, p)
    doc += CGI.htmlTail()

    request.serve_string(doc)
def serve(request):

    c = Collection()
    p = Playlist()
    player = Player()

    doc = CGI.httpHeaders()
    doc += CGI.htmlHead({"style": ["../playlist.css"]})

    if request.command == "POST":
        form = request.form
        if form.has_key("addSongs"):
            for e in makeList(form.getvalue("song")):
                if e is not None:
                    doc += addSong(p, c, e)
        elif form.has_key("addAlbums"):
            for e in makeList(form.getvalue("album")):
                if e is not None:
                    doc += addAlbum(p, c, e)
        elif form.has_key("clear"):
            p.clear()
        elif form.has_key("clearAndStop"):
            p.clear()
            request.state.stop()
            player.stop()

    f = p.update()
    doc += playlistToHtml(f, p)
    doc += CGI.htmlTail()

    request.serve_string(doc)
def serve(request):
    doc = CGI.httpHeaders()
    doc += CGI.htmlHead({ 'markup': [ '<meta http-equiv="Refresh" content="60"/>' ]})

    definedActions =  {
        'Play': { 'action': play },
        'Pause': { 'action': pause },
        'Stop': { 'action': stop },
        'Previous': { 'action': prev },
        'Next': { 'action': next },
        }

    if request.command == "POST":
        form = request.form
        if form.has_key('action'):
            action = form.getvalue('action')
            if definedActions.has_key(action):
                p = Player()
                definedActions[action]['action'](p, request)
                time.sleep(1)
            else:
                request.send_error(406, "Unknown action")

    doc += "<h1>Now playing</h1>"
    doc += browse.currentlyPlaying()

    doc += "<p class='generated'>Status at " + time.ctime() + ".</p>"

    doc += "<h1>Player controls</h1>"
    doc += showActions(definedActions)

    doc += CGI.htmlTail()

    request.serve_string(doc)
def serve(request):
    doc = CGI.httpHeaders()
    doc += CGI.htmlHead()

    definedActions = {
        "Play": {"action": play},
        "Pause": {"action": pause},
        "Stop": {"action": stop},
        "Previous": {"action": prev},
        "Next": {"action": next},
    }

    if request.command == "POST":
        form = request.form
        if form.has_key("action"):
            action = form.getvalue("action")
            if definedActions.has_key(action):
                p = Player()
                definedActions[action]["action"](p, request)
            else:
                doc += "Error!"

    doc += showActions(definedActions)

    doc += CGI.htmlTail()

    return doc
def serve(request):
    doc = CGI.httpHeaders()
    doc += CGI.htmlHead()

    doc += "<p>This is amaroK-juKebox " + Version + ".</p>"
    doc += "<p>For more recent versions, see the <a href='http://amarok-jukebox.berlios.de/'>home page</a>.</p>"

    doc += CGI.htmlTail()

    request.serve_string(doc)
def serve(request):
    doc = CGI.httpHeaders()
    doc += CGI.htmlHead()
    
    c = Collection()
    qp = request.queryParams()

    if request.command == "GET":
        if qp.has_key('artists'):
            doc += artistsHtml(c)
        elif qp.has_key('artist'):
            doc += albumsByArtistHtml(c, qp['artist'][0])
        elif qp.has_key('album'):
            doc += songsByAlbumHtml(c, qp['album'][0])
        else:
            print "Wrong URL!"

    doc += CGI.htmlTail()

    return doc
def main():
    CGI.httpHeaders()
    CGI.htmlHead()
    form = cgi.FieldStorage()

    definedActions = {
        "Play": {"action": play},
        "Pause": {"action": p.playPause},
        "Stop": {"action": p.stop},
        "Previous": {"action": p.prev},
        "Next": {"action": p.next},
    }

    if os.environ["REQUEST_METHOD"] == "GET":
        showActions(definedActions)
    elif os.environ["REQUEST_METHOD"] == "POST":
        if form.has_key("action"):
            action = form.getvalue("action")
            if definedActions.has_key(action):
                definedActions[action]["action"]()
            else:
                print "Error!"
        showActions(definedActions)

    CGI.htmlTail()
def main():

    form = cgi.FieldStorage()

    c = Collection()
    p = Playlist()
    player = Player()

    CGI.httpHeaders()

    CGI.htmlHead({ 'style':['../playlist.css'] })
        
    if os.environ['REQUEST_METHOD'] == "POST":
        if form.has_key('addSongs'):
            for e in makeList(form.getvalue('song')):
                if e is not None:
                    addSong(p, c, e)
        elif form.has_key('addAlbums'):
            for e in makeList(form.getvalue('album')):
                if e is not None:
                    addAlbum(p, c, e)
        elif form.has_key('clear'):
            p.clear()
        elif form.has_key('clearAndStop'):
            p.clear()
            player.stop()

    f = p.update()
    playlistToHtml(f, p)
    CGI.htmlTail()
def serve(request):
    
    qp = request.queryParams()

    if qp.has_key('cover'):
        serveCover(request, qp['cover'][0])
        return ''

    doc = CGI.httpHeaders()
    doc += CGI.htmlHead()
    if qp.has_key('artists'):
        doc += artistsHtml()
    elif qp.has_key('artist'):
        doc += albumsByArtistHtml(qp['artist'][0])
    elif qp.has_key('album'):
        doc += songsByAlbumHtml(qp['album'][0], qp['from'][0])
    elif qp.has_key('song'):
        doc += songHtml(qp['song'][0])
    else:
        request.send_error(406, "What do you want to browse?")
    doc += CGI.htmlTail()

    request.serve_string(doc)
def main():
    CGI.httpHeaders()
    CGI.htmlHead()
    
    form = cgi.FieldStorage()

    c = Collection()

    if os.environ['REQUEST_METHOD'] == "GET":
        if form.has_key('artists'):
            print artistsHtml(c)
        elif form.has_key('artist'):
            print albumsByArtistHtml(c, form['artist'].value)
        elif form.has_key('album'):
            print songsByAlbumHtml(c, form['album'].value)
        else:
            print "Wrong URL!"

    CGI.htmlTail()
Exemple #11
0
#!/usr/bin/python

import sys, argparse, os

sys.path.append("/usr/local/Python")

from File import *
from Path import *
from System import *
from Latex import *
from CGI import *

##
## Generates SVG animation from tikz.tex.

if (CGI().CGI_Is()):
    import cgitb
    cgitb.enable()


class Animation(File, Path, System):
    def __init__(self):

        self.Animation_Args_Init_CLI()
        self.Animation_Run()

    ##!
    ##!
    ##!

    def Animation_Args_Init_CLI(self):
Exemple #12
0
#!/usr/bin/env python3
from werkzeug.wrappers import Request, Response

from get_html import get_html


@Request.application
def run(request):
    html = get_html("index")
    return Response(html, mimetype="text/html")


if __name__ == "__main__":
    import CGI
    CGI.app = run
    CGI.run()
Exemple #13
0
#!/usr/bin/env python3
from werkzeug.wrappers import Request, Response

from get_html import get_html

@Request.application
def run(request):
	html = get_html("index")
	return Response(html, mimetype="text/html")

if __name__ == "__main__":
	import CGI
	CGI.app = run
	CGI.run()
Exemple #14
0
def Process(tikz_file, verbose, noclean):
    path = File().File_Path(tikz_file)
    if (path): path = path + "/"

    pdf_out_file = path + re.sub('\.tikz\.tex', ".pdf",
                                 File().File_BaseName(tikz_file))

    if (not File().File_Exists(tikz_file)):
        System_Error_And_Die([
            "No such file: " + tikz_file, sys.argv[0] + ",usage syntax:",
            "\t" + sys.argv[0] + "file.tikz.tex"
        ])

    pid = "tikz2zip-" + str(os.getpid())

    tex_tmp_path = "/".join([Latex().tmp_path, pid])

    tex_tmp_file = "/".join([
        tex_tmp_path,
        re.sub('\.tikz\.tex', ".tex",
               File().File_BaseName(tikz_file))
    ])

    rel_tex_tmp_file = re.sub('\.tikz\.tex', ".tex",
                              File().File_BaseName(tikz_file))

    zip_file = "/".join([
        tex_tmp_path,
        re.sub('\.tikz\.tex', ".zip",
               File().File_BaseName(tikz_file))
    ])

    latex = Latex().Latex_Document(tikz_file)
    for n in range(len(latex)):
        latex[n] = re.sub('/usr/local/tikz', 'tikz', latex[n])

    File().File_Write(tex_tmp_file, latex, verbose)

    files = Latex().Latex_Inputs(tikz_file, latex)

    main_name = files.pop(0)

    commands = []
    if (not File().File_Exists(tex_tmp_path)):
        os.mkdir(tex_tmp_path)

    files_done = {}

    for fname in files:
        if (files_done.has_key(fname)):
            continue

        rfname = fname
        if (re.search('/usr/local/tikz/', fname)):
            rfname = re.sub('/usr/local/tikz/', 'tikz/', fname)

        path = os.path.dirname(tex_tmp_path + "/" + rfname)

        if (not File().File_Exists(path)):
            os.mkdir(path)

        lines = File_Read(fname)
        for n in range(len(lines)):
            lines[n] = re.sub('/usr/local/tikz', 'tikz', lines[n])

        File().File_Write(tex_tmp_path + "/" + rfname, lines)

        files_done[fname] = rfname

    commands.append([
        "/bin/rm -f",
        zip_file,
    ])

    commands.append([
        "/usr/bin/zip",
        zip_file,
        rel_tex_tmp_file,
    ] + files_done.values())

    res = System().System_Execs(commands, tex_tmp_path, verbose)
    if (CGI().CGI_Is()):
        if (res == 0):
            print "Content-type: application/zip"
            print "Content-Disposition: attachment; filename=" + os.path.basename(
                zip_file)
            print ""

            f = open(zip_file, "rb")
            print f.read()
            f.close()

            exit()

    else:
        zip_in = "/".join([
            #tex_tmp_path,
            zip_file,
        ])

        zip_out = re.sub(r'\.tikz\.tex', "", tikz_file) + '.zip'
        print zip_in, zip_out, 'created'
        System().System_Exec(["/bin/cp", zip_in, zip_out])

    if (not noclean):
        System().System_Exec(["/bin/rm -rf", tex_tmp_path])
Exemple #15
0
parser.add_argument('-v',
                    '-verbose',
                    dest='verbose',
                    action='store_true',
                    help='Echo criation of zip file and other actions take.')

parser.add_argument('-n',
                    '-noclean',
                    dest='noclean',
                    action='store_true',
                    help='Do not delete criated files afterwards.')

verbose = False
noclean = False

if (CGI().CGI_Is()):
    import cgitb
    cgitb.enable()

    tikz_files = ["/".join([
        CGI().CGI_Doc_Root(),
        CGI().CGI_POST("Src"),
    ])]
else:
    args = parser.parse_args()
    tikz_files = args.tikz_files

    verbose = args.verbose
    noclean = args.noclean

#Test arguments