summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Bobov <abobov@gmail.com>2020-01-11 10:02:26 +0500
committerAnton Bobov <abobov@gmail.com>2020-01-11 10:02:26 +0500
commit5294ee60a9fd7afd2d2f36425055e6d12d3e605c (patch)
tree8e9239425fb6f7aff1e4db53d3d9cddf61ca907e
parentc01774dd7649009ed34f0e9adccc22ce908c2f4b (diff)
Updates.
-rwxr-xr-xd-backup26
-rwxr-xr-xledger-price-db-update.py9
2 files changed, 31 insertions, 4 deletions
diff --git a/d-backup b/d-backup
index c0b4cac..5879c77 100755
--- a/d-backup
+++ b/d-backup
@@ -20,8 +20,12 @@ SOURCE=/
print_help() {
cat <<EOF
Commands:
- backup run backup
- stats show collection status
+ backup run backup
+ stats show collection status
+ list list files from backup
+ restore restore files from backup
+Options:
+ --time time specify the time from which to restore or list files
EOF
}
@@ -38,6 +42,14 @@ stats() {
duplicity collection-status "$TARGET"
}
+list() {
+ duplicity list-current-files "$@" "$TARGET"
+}
+
+restore() {
+ duplicity restore "$@" "$TARGET" "$(pwd)"
+}
+
if [[ $# = 0 ]] ; then
print_help
exit 0
@@ -51,6 +63,16 @@ while (( "$#" )) ; do
stats)
stats
;;
+ list)
+ shift
+ list $*
+ exit 0
+ ;;
+ restore)
+ shift
+ restore $*
+ exit 0
+ ;;
*)
print_help
;;
diff --git a/ledger-price-db-update.py b/ledger-price-db-update.py
index 5cf2736..0a78585 100755
--- a/ledger-price-db-update.py
+++ b/ledger-price-db-update.py
@@ -41,6 +41,8 @@ def get_json(url, **kwargs):
def print_price(symbol, price, base, date=datetime.datetime.now()):
date_str = date.strftime('%Y/%m/%d %H:%M:%S')
+ if ' ' in symbol:
+ symbol = '"' + symbol +'"'
print ('P %s %s %f %s' % (date_str, symbol, price, base)).encode('utf-8')
@@ -89,8 +91,11 @@ def bonds():
date = datetime.datetime.now() - datetime.timedelta(days=1)
date_str = date.strftime('%Y-%m-%d')
for short, symbol in symbols:
- if symbol.startswith('SU'):
- url = r'https://iss.moex.com/iss/engines/stock/markets/bonds/boards/TQOB/securities/%s.jsonp?from=%s' % (symbol, date_str)
+ if symbol.startswith('SU') or symbol.startswith('RU'):
+ if symbol.startswith('SU'):
+ url = r'https://iss.moex.com/iss/engines/stock/markets/bonds/boards/TQOB/securities/%s.jsonp?from=%s' % (symbol, date_str)
+ else:
+ url = r'https://iss.moex.com/iss/engines/stock/markets/bonds/boards/EQOB/securities/%s.jsonp?from=%s' % (symbol, date_str)
data = get_json(url)['securities']
price = get_moex_value(data, 'PREVPRICE')
value = get_moex_value(data, 'FACEVALUE')