Skip to content

Commit

Permalink
add zip compression and the ability to remove the logfiles
Browse files Browse the repository at this point in the history
Signed-off-by: Sandmann79 <sandmann79@gmx.net>
  • Loading branch information
Sandmann79 committed Mar 21, 2023
1 parent 5eb4bfe commit 5134659
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 6 deletions.
Expand Up @@ -817,4 +817,8 @@ msgstr "HTTP-Antwortinhalt loggen"

msgctxt "#30275"
msgid "Create Logfiles archive"
msgstr "Logdateien-Archiv erstellen"
msgstr "Logdateien-Archiv erstellen"

msgctxt "#30276"
msgid "Clear Logfiles"
msgstr "Logdateien löschen"
Expand Up @@ -828,4 +828,8 @@ msgstr ""

msgctxt "#30275"
msgid "Create Logfiles archive"
msgstr ""

msgctxt "#30276"
msgid "Clear Logfiles"
msgstr ""
Expand Up @@ -819,3 +819,7 @@ msgstr ""
msgctxt "#30275"
msgid "Create Logfiles archive"
msgstr ""

msgctxt "#30276"
msgid "Clear Logfiles"
msgstr ""
Expand Up @@ -819,3 +819,7 @@ msgstr ""
msgctxt "#30275"
msgid "Create Logfiles archive"
msgstr ""

msgctxt "#30276"
msgid "Clear Logfiles"
msgstr ""
Expand Up @@ -824,3 +824,7 @@ msgstr ""
msgctxt "#30275"
msgid "Create Logfiles archive"
msgstr ""

msgctxt "#30276"
msgid "Clear Logfiles"
msgstr ""
Expand Up @@ -834,3 +834,7 @@ msgstr ""
msgctxt "#30275"
msgid "Create Logfiles archive"
msgstr ""

msgctxt "#30276"
msgid "Clear Logfiles"
msgstr ""
Expand Up @@ -818,3 +818,7 @@ msgstr ""
msgctxt "#30275"
msgid "Create Logfiles archive"
msgstr ""

msgctxt "#30276"
msgid "Clear Logfiles"
msgstr ""
Expand Up @@ -823,3 +823,7 @@ msgstr ""
msgctxt "#30275"
msgid "Create Logfiles archive"
msgstr ""

msgctxt "#30276"
msgid "Clear Logfiles"
msgstr ""
Expand Up @@ -835,3 +835,7 @@ msgstr ""
msgctxt "#30275"
msgid "Create Logfiles archive"
msgstr ""

msgctxt "#30276"
msgid "Clear Logfiles"
msgstr ""
13 changes: 9 additions & 4 deletions plugin.video.amazon-test/resources/lib/logging.py
Expand Up @@ -78,18 +78,23 @@ def LogJSON(o, comment=None, optionalName=None):


def CreateZIP():
import os
from zipfile import ZipFile
from zipfile import ZipFile, ZIP_DEFLATED
from datetime import datetime
from .common import py2_decode, translatePath

kodilog = OSPJoin(py2_decode(translatePath('special://logpath')), 'kodi.log')
arcfile = OSPJoin(g.DATA_PATH, 'logfiles_{}.zip'.format(datetime.now().strftime('%Y%m%d-%H%M%S')))
arc = ZipFile(arcfile, 'w')
arc = ZipFile(arcfile, 'w', ZIP_DEFLATED)

for fn in os.listdir(g.LOG_PATH):
for fn in xbmcvfs.listdir(g.LOG_PATH)[1]:
arc.write(OSPJoin(g.LOG_PATH, fn), arcname=(OSPJoin('log', fn)))
arc.write(kodilog, arcname='kodi.log')
arc.close()
g.dialog.notification(g.__plugin__, 'Archive created at {}'.format(arcfile))
Log('Archive created at {}'.format(arcfile), Log.DEBUG)


def RemoveLogs():
for fn in xbmcvfs.listdir(g.LOG_PATH)[1]:
xbmcvfs.delete(OSPJoin(g.LOG_PATH, fn))
Log('Logfiles removed', Log.DEBUG)
2 changes: 2 additions & 0 deletions plugin.video.amazon-test/resources/lib/startup.py
Expand Up @@ -82,5 +82,7 @@ def EntryPoint():
exec('{}()'.format(mode))
elif mode in ['createzip']:
CreateZIP()
elif mode in ['rmlogs']:
RemoveLogs()
else:
g.pv.Route(mode, args)
3 changes: 2 additions & 1 deletion plugin.video.amazon-test/resources/settings.xml
Expand Up @@ -126,6 +126,7 @@
<setting id="json_dump_raw" type="bool" label="30199" default="false" enable="eq(-1,true)" subsetting="true"/>
<setting id="json_dump_collisions" type="bool" label="30197" default="false" enable="eq(-2,true)" subsetting="true"/>
<setting id="log_http" type="bool" label="30274" default="false"/>
<setting id="create_zip" label="30275" type="action" action="RunPlugin(plugin://plugin.video.amazon-test/?mode=createzip)" option="close"/>
<setting id="create_zip" label="30275" type="action" action="RunPlugin(plugin://plugin.video.amazon-test/?mode=createzip)"/>
<setting id="rm_logs" label="30276" type="action" action="RunPlugin(plugin://plugin.video.amazon-test/?mode=rmlogs)"/>
</category>
</settings>

0 comments on commit 5134659

Please sign in to comment.