1
from datetime import datetime;
2
from dateutil.relativedelta import relativedelta;
4
import protoborsaconfig;
5
#gets a list and return a dictionary for plotting with pycha.
7
how pycha wants a list of dictionary... for axis ticks:
8
[{'v': 0, 'label': 'day1'},
9
{'v': 1, 'label': 'day2'},
10
{'v': 2, 'label': 'day3'}]
12
def getAxisTicks(days):
17
ticks.append({'v': i, 'label': day});
19
ticks.append({'v': i, 'label': ''});
24
def getDayMonth(ydate):
25
return ydate[8:10] + '/' + ydate[5:7];
28
def getLastMonth4YEnd():
29
return (datetime.now() + relativedelta(days=-1)).strftime('%Y%m%d');
31
def getLastMonth4YBegin():
32
return (datetime.now() + relativedelta(months=-1,days=-1)).strftime('%Y%m%d');
35
return os.getenv("HOME")+"/.protoborsa/stocksymbols.db";
38
settDirectory = os.getenv("HOME")+"/.protoborsa/";
39
dbFile = "stocksymbols.db";
40
destDir = protoborsaconfig.get_data_path() + "/db/" + dbFile;
42
if not os.path.exists(settDirectory):
43
os.makedirs(settDirectory);
44
cmdStr = "cp "+destDir+" "+settDirectory;
45
print "Creating settings directory, copy file there "+cmdStr;
49
fname = settDirectory + "/"+dbFile;
50
if(os.path.isfile(fname)):
51
print "Settings file found";
54
print "Settings file non found"+fname;
55
cmdStr = "cp "+destDir+" "+settDirectory;
56
print "Creating settings directory, copy file there "+cmdStr;