Sort pisg outputs into user/network dirs
This commit is contained in:
parent
12994f3bea
commit
3d1adaf31b
12
pisg.py
12
pisg.py
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import subprocess
|
import subprocess
|
||||||
from os import listdir,unlink,chdir
|
from os import listdir,unlink,chdir,mkdir
|
||||||
from os.path import exists
|
from os.path import exists
|
||||||
from sys import exit
|
from sys import exit
|
||||||
from random import randint
|
from random import randint
|
||||||
|
@ -28,7 +28,7 @@ class logfile:
|
||||||
<set ShowKarma="1">
|
<set ShowKarma="1">
|
||||||
<set KarmaHistory="15">
|
<set KarmaHistory="15">
|
||||||
<set TopicHistory="25">
|
<set TopicHistory="25">
|
||||||
<set PicLocation="gfx">
|
<set PicLocation="/gfx">
|
||||||
<set UserPics="1">
|
<set UserPics="1">
|
||||||
<set ActiveNicks="50">
|
<set ActiveNicks="50">
|
||||||
<set CacheDir="/home/znc/pisg/cache">
|
<set CacheDir="/home/znc/pisg/cache">
|
||||||
|
@ -38,17 +38,20 @@ class logfile:
|
||||||
Logfile = "%(logdir)s_*.log"
|
Logfile = "%(logdir)s_*.log"
|
||||||
Format = "energymech"
|
Format = "energymech"
|
||||||
Network = "%(network)s"
|
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}
|
</channel>""" % {"logdir":self.path, "network":self.network, "channel":self.channel, "username":self.username}
|
||||||
|
|
||||||
def run_pisg(self):
|
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))
|
configname = "config.%s" % str(randint(0,10000))
|
||||||
open(configname, "w").write(self.generate_config())
|
open(configname, "w").write(self.generate_config())
|
||||||
proc = subprocess.Popen(['pisg',"-co", configname], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
proc = subprocess.Popen(['pisg',"-co", configname], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
print(self.path +": "+str(proc.communicate()))
|
print(self.path +": "+str(proc.communicate()))
|
||||||
unlink(configname)
|
unlink(configname)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
chdir("/home/znc/pisg")
|
chdir("/home/znc/pisg")
|
||||||
logs = []
|
logs = []
|
||||||
|
@ -74,4 +77,3 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
for log in logs:
|
for log in logs:
|
||||||
log.run_pisg()
|
log.run_pisg()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue