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) )
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))
def manage_repository_page(repository, message="", status=True): provisioning.print_html_header("Repository Management") try: provisioning.print_manage_btn() provisioning.goto_rep_box(repository, 1) # Shows heading with repository title and description print "<h3>%s</h3><p>%s</p>" % (repository.title, repository.description) # Shows brief repository info files_count = len(os.listdir(repository.path)) print """ <strong>Name:</strong> <em>%s</em><br> <strong>URI:</strong> <em>%s</em><br> <strong>Web home:</strong> <em><a href="%s">%s</a></em><br> <strong>Files count:</strong> <em>%d</em><br> """ % (repository.name, repository.url, repository.web, repository.web, files_count) # Shows status of previous operation if not message == "": if status == True: print "<div class=message>%s</div>" % (message) else: print "<div class=error_message>%s</div>" % (message) # Add a new file form print "<center>" 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>"