def process_dir_html(repository):
    try:
        provisioning.print_html_header("Repository Content")
        provisioning.print_manage_btn()
        provisioning.goto_rep_box(repository)
        
        print "<h3>%s</h3><p>%s</p>" % (repository.title, repository.description)
        files_count = len(os.listdir(repository.path))
        print "<center>"
        if files_count>0: print_rep_table(repository)
        else: print "<p>The repository is empty.</p>"
        print "</center>"
        provisioning.print_html_footer()
    except Exception, e:
        print "<div class=error_message>An error occured.</div>"
        sys.stderr.write("%s, %s" % (Exception ,e) )
Example #2
0
def process_dir_html(repository):
    try:
        provisioning.print_html_header("Repository Content")
        provisioning.print_manage_btn()
        provisioning.goto_rep_box(repository)

        print "<h3>%s</h3><p>%s</p>" % (repository.title,
                                        repository.description)
        files_count = len(os.listdir(repository.path))
        print "<center>"
        if files_count > 0: print_rep_table(repository)
        else: print "<p>The repository is empty.</p>"
        print "</center>"
        provisioning.print_html_footer()
    except Exception, e:
        print "<div class=error_message>An error occured.</div>"
        sys.stderr.write("%s, %s" % (Exception, e))
Example #3
0
            <span>Add a new file:</span>
            <input type=hidden value=%s name=repository>
            <input type=file size=40 value=%s accept="*.*" name=add_file>
            <input type=Submit value="Add"></input>
            </form>
            """ % (provisioning.SERVER.admin_console(), repository.name,
                   repository.path)

        # Shows repository content
        if files_count > 0: print_rep_table(repository)
        else: print "<p>The repository is empty.</p></center>"
    except Exception, e:
        print "<div class=error_message>Sorry, an error occured.</div>"
        sys.stderr.write("Cannot show 'manage repository page': %s, %s" %
                         (Exception, e))
    provisioning.print_html_footer()


# Draws repository content table with 'delete' option
# @param repository
def print_rep_table(repository):
    print "<table class=table cellpadding=3 cellspacing=0><tr class=table_header>"
    for title in ["File Name", "Size", "Time"]:
        print "<td>%s</td>" % (title)
    print "<td class=screen>&nbsp;</td>"
    print "</tr>"

    odd = True
    for x in os.listdir(repository.path):
        fullname = join(repository.path, x)
        if odd: print "<tr class=odd_row>"
        print """
            <form action=%s enctype=multipart/form-data method=post class=screen>
            <span>Add a new file:</span>
            <input type=hidden value=%s name=repository>
            <input type=file size=40 value=%s accept="*.*" name=add_file>
            <input type=Submit value="Add"></input>
            </form>
            """ % (provisioning.SERVER.admin_console(), repository.name, repository.path)
        
        # Shows repository content
        if files_count > 0: print_rep_table(repository)
        else: print "<p>The repository is empty.</p></center>"
    except Exception, e:
        print "<div class=error_message>Sorry, an error occured.</div>"
        sys.stderr.write("Cannot show 'manage repository page': %s, %s" %(Exception, e))
    provisioning.print_html_footer()

# Draws repository content table with 'delete' option
# @param repository
def print_rep_table(repository):    
    print "<table class=table cellpadding=3 cellspacing=0><tr class=table_header>"
    for title in ["File Name", "Size", "Time"]:
        print "<td>%s</td>" % (title)
    print "<td class=screen>&nbsp;</td>"
    print "</tr>"

    odd = True
    for x in os.listdir(repository.path):
        fullname = join(repository.path, x)
        if odd: print "<tr class=odd_row>"
        else:   print "<tr class=even_row>"