Sort pisg outputs into user/network dirs

master
dave 8 years ago
parent 12994f3bea
commit 3d1adaf31b

@ -1,6 +1,6 @@
#!/usr/bin/env python3
import subprocess
from os import listdir,unlink,chdir
from os import listdir,unlink,chdir,mkdir
from os.path import exists
from sys import exit
from random import randint
@ -28,7 +28,7 @@ class logfile:
<set ShowKarma="1">
<set KarmaHistory="15">
<set TopicHistory="25">
<set PicLocation="gfx">
<set PicLocation="/gfx">
<set UserPics="1">
<set ActiveNicks="50">
<set CacheDir="/home/znc/pisg/cache">
@ -38,16 +38,19 @@ class logfile:
Logfile = "%(logdir)s_*.log"
Format = "energymech"
Network = "%(network)s"
OutputFile = "/home/znc/pisg/output/%(username)s_%(network)s_%(channel)s.html"
OutputFile = "/home/znc/pisg/output/%(username)s/%(network)s/%(channel)s.html"
</channel>""" % {"logdir":self.path, "network":self.network, "channel":self.channel, "username":self.username}
def run_pisg(self):
if not exists("/home/znc/pisg/output/%s" % self.username):
mkdir("/home/znc/pisg/output/%s" % self.username)
if not exists("/home/znc/pisg/output/%s/%s" % (self.username, self.network)):
mkdir("/home/znc/pisg/output/%s/%s" % (self.username, self.network))
configname = "config.%s" % str(randint(0,10000))
open(configname, "w").write(self.generate_config())
proc = subprocess.Popen(['pisg',"-co", configname], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print(self.path +": "+str(proc.communicate()))
unlink(configname)
if __name__ == "__main__":
chdir("/home/znc/pisg")
@ -74,4 +77,3 @@ if __name__ == "__main__":
for log in logs:
log.run_pisg()

Loading…
Cancel
Save