Browse Source

dunno

pull/1/head
Jeffrey Paul 8 years ago
parent
commit
28c095279c
6 changed files with 61 additions and 4 deletions
  1. +1
    -0
      .gitignore
  2. +5
    -3
      homedir.makefile/Makefile
  3. +41
    -0
      linuxnet2statsd/report_net_stats.py
  4. +4
    -0
      scrapers/amexscraper.py
  5. +4
    -0
      scrapers/etradescraper.py
  6. +6
    -1
      scrapers/scraper.py

+ 1
- 0
.gitignore View File

@@ -1 +1,2 @@
.DS_Store
*.pyc

+ 5
- 3
homedir.makefile/Makefile View File

@@ -31,14 +31,16 @@ mailoffsite: imapbackup
databackup: dvbackup imapbackup
backup.command

clean:
cleanup:
-mkdir -p $(HOME)/Documents/$(YYYYMM)
-mv $(HOME)/Desktop/* $(HOME)/Documents/$(YYYYMM)

clean: cleanup
@echo $(PREFIX) $@ $(SUFFIX)
@-rm -rf ~/tmp/*
@-rm -rf ~/Library/Caches/*
@-rm -rf ~/.Trash/*
@-rm -rf $(JUNKFILES)
-mkdir -p $(HOME)/Documents/$(YYYYMM)
-mv $(HOME)/Desktop/* $(HOME)/Documents/$(YYYYMM)

size:
du -sh $(HOME)

+ 41
- 0
linuxnet2statsd/report_net_stats.py View File

@@ -0,0 +1,41 @@
#!/usr/bin/python
from pystatsd import Client

class LinuxNetStats(object):
def __init__(self):
self.d = self._get()

def _get(self):
# thx
# http://stackoverflow.com/questions/1052589/
# how-can-i-parse-the-output-of-proc-net-dev-
# into-keyvalue-pairs-per-interface-u
lines = open("/proc/net/dev", "r").readlines()
columnLine = lines[1]
_, receiveCols , transmitCols = columnLine.split("|")
receiveCols = map(lambda a:"rx_"+a, receiveCols.split())
transmitCols = map(lambda a:"tx_"+a, transmitCols.split())
cols = receiveCols+transmitCols
faces = {}
for line in lines[2:]:
if line.find(":") < 0: continue
face, data = line.split(":")
face = face.lstrip()
faces[face] = dict(zip(cols, data.split()))
return faces

def forStatsd(self,prefix=''):
out = {}
for iface in self.d.keys():
for kn in self.d[iface].keys():
out['%s%s.%s' % (prefix, iface, kn)] = int(self.d[iface][kn])
return out

def main():
s = Client('localhost',8125)
n = LinuxNetStats()
for k,v in n.forStatsd(prefix='host.com.eeqj.net.').items():
s.update_stats(k,v)

if __name__=="__main__":
main()

+ 4
- 0
scrapers/amexscraper.py View File

@@ -12,6 +12,10 @@ from ofxclient.request import Builder as OFXClientBuilder
from scraper import FinancialScraper, MockInstitution

class AmexScraper(FinancialScraper):
def isBank(self):
return False
def isCC(self):
return True
def getInstitution(self):
return MockInstitution(
user=self.user,

+ 4
- 0
scrapers/etradescraper.py View File

@@ -10,6 +10,10 @@ import json
from scraper import FinancialScraper, MockInstitution

class EtradeScraper(FinancialScraper):
def isBank(self):
return True
def isCC(self):
return False
def getInstitution(self):
return MockInstitution(
user=self.user,

+ 6
- 1
scrapers/scraper.py View File

@@ -4,6 +4,7 @@
# 2013 jeffrey paul <sneak@datavibe.net>
# 5539 AD00 DE4C 42F3 AFE1 1575 0524 43F4 DF2A 55C2

from pprint import pformat
import os
import re
from ofxclient.request import Builder as OFXClientBuilder
@@ -32,8 +33,12 @@ class FinancialScraper(object):
out = {}
for acctnum in re.findall(c,r):
out[acctnum] = {}
print(pformat(out))
c = re.compile(r'<BALAMT>([\d\.\-]+)', re.MULTILINE)
for acctnum in out.keys():
r = b.doQuery(b.ccQuery(acctnum,'19700101000000'))
if self.isCC():
r = b.doQuery(b.ccQuery(acctnum,'19700101000000'))
if self.isBank():
r = b.doQuery(b.baQuery(acctnum,'19700101000000','',''))
out[acctnum]['balance'] = re.findall(c,r)[0]
return out

Loading…
Cancel
Save