This commit is contained in:
Jeffrey Paul 2013-03-27 08:32:34 +01:00
parent 258b2d3baf
commit 28c095279c
6 changed files with 61 additions and 4 deletions

1
.gitignore vendored
View File

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

View File

@ -31,14 +31,16 @@ mailoffsite: imapbackup
databackup: dvbackup imapbackup databackup: dvbackup imapbackup
backup.command backup.command
clean: cleanup:
-mkdir -p $(HOME)/Documents/$(YYYYMM)
-mv $(HOME)/Desktop/* $(HOME)/Documents/$(YYYYMM)
clean: cleanup
@echo $(PREFIX) $@ $(SUFFIX) @echo $(PREFIX) $@ $(SUFFIX)
@-rm -rf ~/tmp/* @-rm -rf ~/tmp/*
@-rm -rf ~/Library/Caches/* @-rm -rf ~/Library/Caches/*
@-rm -rf ~/.Trash/* @-rm -rf ~/.Trash/*
@-rm -rf $(JUNKFILES) @-rm -rf $(JUNKFILES)
-mkdir -p $(HOME)/Documents/$(YYYYMM)
-mv $(HOME)/Desktop/* $(HOME)/Documents/$(YYYYMM)
size: size:
du -sh $(HOME) du -sh $(HOME)

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()

View File

@ -12,6 +12,10 @@ from ofxclient.request import Builder as OFXClientBuilder
from scraper import FinancialScraper, MockInstitution from scraper import FinancialScraper, MockInstitution
class AmexScraper(FinancialScraper): class AmexScraper(FinancialScraper):
def isBank(self):
return False
def isCC(self):
return True
def getInstitution(self): def getInstitution(self):
return MockInstitution( return MockInstitution(
user=self.user, user=self.user,

View File

@ -10,6 +10,10 @@ import json
from scraper import FinancialScraper, MockInstitution from scraper import FinancialScraper, MockInstitution
class EtradeScraper(FinancialScraper): class EtradeScraper(FinancialScraper):
def isBank(self):
return True
def isCC(self):
return False
def getInstitution(self): def getInstitution(self):
return MockInstitution( return MockInstitution(
user=self.user, user=self.user,

View File

@ -4,6 +4,7 @@
# 2013 jeffrey paul <sneak@datavibe.net> # 2013 jeffrey paul <sneak@datavibe.net>
# 5539 AD00 DE4C 42F3 AFE1 1575 0524 43F4 DF2A 55C2 # 5539 AD00 DE4C 42F3 AFE1 1575 0524 43F4 DF2A 55C2
from pprint import pformat
import os import os
import re import re
from ofxclient.request import Builder as OFXClientBuilder from ofxclient.request import Builder as OFXClientBuilder
@ -32,8 +33,12 @@ class FinancialScraper(object):
out = {} out = {}
for acctnum in re.findall(c,r): for acctnum in re.findall(c,r):
out[acctnum] = {} out[acctnum] = {}
print(pformat(out))
c = re.compile(r'<BALAMT>([\d\.\-]+)', re.MULTILINE) c = re.compile(r'<BALAMT>([\d\.\-]+)', re.MULTILINE)
for acctnum in out.keys(): for acctnum in out.keys():
if self.isCC():
r = b.doQuery(b.ccQuery(acctnum,'19700101000000')) 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] out[acctnum]['balance'] = re.findall(c,r)[0]
return out return out