Download config and database from the settings

This commit is contained in:
JonnyWong16 2017-04-22 13:23:16 -07:00
commit 84bfe99017
3 changed files with 43 additions and 5 deletions

View file

@ -3630,6 +3630,37 @@ class WebInterface(object):
return serve_file(path=fp, content_type='image/png')
@cherrypy.expose
@requireAuth(member_of("admin"))
@addtoapi()
def download_config(self, **kwargs):
""" Download the PlexPy configuration file. """
config_file = config.FILENAME
try:
plexpy.CONFIG.write()
except:
pass
return serve_download(plexpy.CONFIG_FILE, name=config_file)
@cherrypy.expose
@requireAuth(member_of("admin"))
@addtoapi()
def download_database(self, **kwargs):
""" Download the PlexPy database file. """
database_file = database.FILENAME
try:
db = database.MonitorDatabase()
db.connection.execute('begin immediate')
shutil.copyfile(plexpy.DB_FILE, os.path.join(plexpy.CONFIG.CACHE_DIR, database_file))
db.connection.rollback()
except:
pass
return serve_download(os.path.join(plexpy.CONFIG.CACHE_DIR, database_file), name=database_file)
@cherrypy.expose
@requireAuth(member_of("admin"))
@addtoapi()