Esempio n. 1
0
def read(path):
    """读取路径下的文件"""
    user_id = os.environ.get("JUPYTERHUB_USER") or ""
    if not path.startswith("/"):
        path = rela2abs(path)

    with get_engine().begin() as db:
        src_file = get_file(db, user_id, path, True,
                            crypto.NoEncryption().decrypt)
    return b64decode(src_file['content'].decode("utf-8"))
Esempio n. 2
0
 def post(self): 
     usr= tornado.escape.xhtml_escape(self.current_user)
     #print "I got a request!"
     #print self.request.arguments
     file='/'+self.get_argument("file")
     name=split_api_filepath(file)[1]
     db=create_engine('postgresql://*****:*****@localhost/ishtar')
     binarycontent=pgquery.get_file(db, usr, file, include_content=True)['content'] 
     db.dispose()
     with create_engine('postgresql://*****:*****@localhost/ishtar').begin() as db:
         pgquery.save_file(db, 'share', '/export/'+name, binarycontent, 0)
Esempio n. 3
0
        def post(self): 
            name = tornado.escape.xhtml_escape(self.current_user)
            path=self.get_argument("path")
            directory=self.get_argument("directory")
            if directory[-1] != '/':
                directory=directory+'/'

            db=create_engine('postgresql://*****:*****@localhost/ishtar')
            binarycontent=pgquery.get_file(db, "share", path, include_content=True)['content']   
            db.dispose()
            with create_engine('postgresql://*****:*****@localhost/ishtar').begin() as db:
                pgquery.save_file(db, name, directory+split_api_filepath(path)[1], binarycontent, 0)
            self.redirect('/shared')
Esempio n. 4
0
        def post(self): 
          id=self.get_argument("path")
          print id
          db=create_engine('postgresql://*****:*****@localhost/ishtar')
        
          fileContent=reads_base64(pgquery.get_file(db, "share", id, include_content=True)['content'])
          #notebook= nbformat.reads(fileContent, as_version=4)
          notebook=fileContent
          db.dispose()
          html_exporter = HTMLExporter()
          html_exporter.template_file = 'basic'

          (body, resources) = html_exporter.from_notebook_node(notebook)
          self.write(body)
Esempio n. 5
0
def loadFile(filename,shared=False)   :
    if shared:
        usr="******"
    else:
        env=os.environ.copy()
        usr=env["USRGILGA"]
    db=create_engine('postgresql://*****:*****@localhost/ishtar')
    binarycontent=pgquery.get_file(db, usr, filename, include_content=True)['content']   
    db.dispose()
    return StringIO.StringIO(binarycontent.decode('base64'))