def get_paste(paste_id, raw=None): """Fetch and return a paste.""" stats = os.stat(utils.get_directory("pastes") + paste_id) st_mtime = time.ctime(stats.st_mtime) st_size = stats.st_size paste = utils.read_file("pastes", paste_id) if not paste: flask.abort(404) if raw: return flask.Response(paste, status=200, mimetype="text/plain") return flask.render_template( "paste.html", paste_id=paste_id, paste=cgi.escape(paste), st_mtime=st_mtime, st_size=st_size, version=version.version_string())
def test_get_directory(self): new_dir = utils.get_home_directory() + "test_dir" self.assertFalse(os.path.exists(new_dir)) utils.get_directory("test_dir") self.assertTrue(os.path.exists(new_dir)) os.rmdir(new_dir)
def __init__(self, irc): self.irc = irc self.name = self.__class__.__name__ self.launchpad = LP.login_anonymously("pyhole", "production", utils.get_directory(self.name))
def __init__(self, session): self.session = session self.name = self.__class__.__name__ self.launchpad = LP.login_anonymously("pyhole", "production", utils.get_directory(self.name))
def test_get_directory(self): new_dir = utils.get_home_directory() + "test_dir/" actual_dir = utils.get_directory("test_dir") self.assertEqual(new_dir, actual_dir) os.rmdir(new_dir)