]> gitweb.pimeys.fr Git - scripts-20-100.git/blob - mystats.py
[bde] depenses.py : inversion gains/dépenses
[scripts-20-100.git] / mystats.py
1 #!/usr/bin/python
2 # -*- coding:utf-8 -*-
3
4 """Codé par 20-100 une nuit où il trouvait qu'il parlait beaucoup sur #note-dev
5
6 Ne marche plus parce que sous WeeChat les paths ont changé et j'ai eu la
7 flemme de corriger jusqu'ici.
8 """
9
10 import sys
11 import os
12 os.chdir("/home/legallic/.weechat/logs/crans/")
13
14 try:
15 chan = sys.argv[1]
16 except:
17 print "Usage : mystats.py <chan>"
18 exit(1)
19
20 from commands import getstatusoutput as ex
21
22 cmdlignes = r"cat */*/%s.log | grep '^........<' | wc -l"%(chan)
23 cmdmeslignes = r"cat */*/%s.log | grep '^........<.\[20-100\]' | wc -l"%(chan)
24 lignes = int(ex(cmdlignes)[1])
25 meslignes = int(ex(cmdmeslignes)[1])
26 print "messages = %s/%s, %s%%"%(meslignes,lignes,int(1000*meslignes/float(lignes))/10.0)
27 mess = (meslignes,lignes)
28
29 cmdlignes = r"cat */*/%s.log | grep '^........ [*]' | wc -l"%(chan)
30 cmdmeslignes = r"cat */*/%s.log | grep '^........ [*] \[20-100\]' | wc -l"%(chan)
31 lignes = int(ex(cmdlignes)[1])
32 meslignes = int(ex(cmdmeslignes)[1])
33 print "actions = %s/%s, %s%%"%(meslignes,lignes,int(1000*meslignes/float(lignes))/10.0)
34 acts = (meslignes,lignes)
35
36 tot=(mess[0]+acts[0],mess[1]+acts[1])
37 print "total = %s/%s, %s%%"%(tot[0],tot[1],int(1000*tot[0]/float(tot[1]))/10.0)