예제 #1
0
    def browser(path=None):
        uploads_dir = app.config['UPLOADS_DIRECTORY']
        path_join = op.join(uploads_dir, path)

        # if path is toplevel output dir, check for result tarball
        # if tarball exists, trigger output download
        if path.endswith('-output'):
            result_targz = '{0}.tar.gz'.format(path)
            result_path = op.join(uploads_dir, result_targz)
            if op.exists(result_path):
                return redirect(url_for('download', path=result_targz))

        # if result file not ready yet, let user browse the run directory
        if op.isdir(path_join):
            folder = Folder(uploads_dir, path)
            folder.read()
            return render_template('folder.html', folder=folder)
        else:
            my_file = File(uploads_dir, path)
            context = my_file.apply_action(View)
            folder = Folder(uploads_dir, my_file.get_path())
            if context == None:
                return render_template('file_unreadable.html', folder=folder)
            return render_template('file_view.html',
                                   text=context['text'],
                                   file=my_file,
                                   folder=folder)
예제 #2
0
def hello(path=''):
    path_join = os.path.join(app.config['FILES_ROOT'], path)

#if path_join is folder
 
    if os.path.isdir(path_join):
        folder = Folder(app.config['FILES_ROOT'], path)
        folder.read()
        return render_template('folder.html', folder=folder)
    else:
    # if path join is  a file
    
        my_file = File(app.config['FILES_ROOT'], path)
        
        context = my_file.apply_action(View)
        folder = Folder(app.config['FILES_ROOT'], my_file.get_path())
        if context == None:

            folder = my_file.path
            return send_file(folder)
#                return render_template('file_unreadable.html', folder=folder)
        
        # text = context['text'] file da text return karda hai.
        #eh text e pure svg hai
       
       
        return render_template('file_view.html', text=context['text'], \
        file=my_file, folder=folder)
예제 #3
0
def index(path=''):
    path_join = os.path.join(app.config['FILES_ROOT'], path)
    if os.path.isdir(path_join):
        folder = Folder(app.config['FILES_ROOT'], path)
        folder.read()
        return render_template('folder.html', folder=folder)
    else:
        my_file = File(app.config['FILES_ROOT'], path)
        context = my_file.apply_action(View)
        folder = Folder(app.config['FILES_ROOT'], my_file.get_path())
        if context == None:
            return render_template('file_unreadable.html', folder=folder)
        return render_template('file_view.html', text=context['text'], file=my_file, folder=folder)
예제 #4
0
def index(path=''):
    path_join = os.path.join(app.config['FILES_ROOT'], path)
    if os.path.isdir(path_join):
        folder = Folder(app.config['FILES_ROOT'], path)
        folder.read()
        return render_template('folder.html', folder=folder)
    else:
        my_file = File(app.config['FILES_ROOT'], path)
        context = my_file.apply_action(View)
        folder = Folder(app.config['FILES_ROOT'], my_file.get_path())
        if context is None:
            return render_template('file_unreadable.html', folder=folder)
        return render_template('file_view.html',
                               text=context['text'],
                               file=my_file,
                               folder=folder)
예제 #5
0
def index(path=""):
    path_join = os.path.join(app.config["FILES_ROOT"], path)
    if os.path.isdir(path_join):
        folder = Folder(app.config["FILES_ROOT"], path)
        folder.read()
        return render_template("folder.html", folder=folder)
    else:
        my_file = File(app.config["FILES_ROOT"], path)
        context = my_file.apply_action(View)
        folder = Folder(app.config["FILES_ROOT"], my_file.get_path())
        if context == None:

            raw_file = my_file.path

            return send_file(raw_file)

        return render_template("file_view.html", text=context["text"], file=my_file, folder=folder)
예제 #6
0
def view_content(path=''):
    print "hello"

    app.config.update(
        DEBUG=True,
        FILES_ROOT=os.path.dirname(os.path.abspath(__file__)),
    )
    path_join = os.path.join(app.config['FILES_ROOT'], path)
    my_file = File(app.config['FILES_ROOT'], path)
    context = my_file.apply_action(View)
    folder = Folder(app.config['FILES_ROOT'], my_file.get_path())
    if context == None:
        return render_template('file_unreadable.html', folder=folder)
    return render_template('file_view.html',
                           text=context['text'],
                           file=my_file,
                           folder=folder)
예제 #7
0
파일: run.py 프로젝트: yopming/Gandolf
def index(path=''):
    path_join = os.path.join(app.config['FILES_ROOT'], path)
    if os.path.isdir(path_join):
        # If the mouse click the folder
        folder = Folder(app.config['FILES_ROOT'], path)
        folder.read()
        return render_template(
            'folder.html',
            folder=folder,
            cdn_root=app.config['CDN_ROOT'],
            request=request
        )

    else:
        # If the mouse click the file
        my_file = File(app.config['FILES_ROOT'], path)
        folder = Folder(app.config['FILES_ROOT'], my_file.get_path())
        return render_template('file_view.html', file=my_file, folder=folder)
예제 #8
0
    def browser(path=None):
        uploads_dir = app.config['UPLOADS_DIRECTORY']
        path_join = op.join(uploads_dir, path)

        # if path is toplevel output dir, check for result tarball
        # if tarball exists, trigger output download
        if path.endswith('-output'):
            result_targz = '{0}.tar.gz'.format(path)
            result_path = op.join(uploads_dir, result_targz)
            if op.exists(result_path):
                return redirect(url_for('download', path=result_targz))

        # if result file not ready yet, let user browse the run directory
        if op.isdir(path_join):
            folder = Folder(uploads_dir, path)
            folder.read()
            return render_template('folder.html', folder=folder)
        else:
            my_file = File(uploads_dir, path)
            context = my_file.apply_action(View)
            folder = Folder(uploads_dir, my_file.get_path())
            if context == None:
                return render_template('file_unreadable.html', folder=folder)
            return render_template('file_view.html', text=context['text'], file=my_file, folder=folder)