electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit e9f5e6866dd51532f9b36d82f0607a74d15251ea
parent 2edd0f248abc1e689128d6a9d1360f3367a6a151
Author: ThomasV <thomasv@gitorious>
Date:   Sat, 25 Jul 2015 12:25:47 +0200

check www dir on daemon start

Diffstat:
Mlib/daemon.py | 27+++++++++++++++++++++++++++
Mlib/wallet.py | 24------------------------
2 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/lib/daemon.py b/lib/daemon.py @@ -207,6 +207,30 @@ def daemon_loop(server): print_error("Daemon exiting") + +def check_www_dir(rdir): + # rewrite index.html every time + import urllib, urlparse, shutil, os + if not os.path.exists(rdir): + os.mkdir(rdir) + index = os.path.join(rdir, 'index.html') + src = os.path.join(os.path.dirname(__file__), 'www', 'index.html') + shutil.copy(src, index) + files = [ + "https://code.jquery.com/jquery-1.9.1.min.js", + "https://raw.githubusercontent.com/davidshimjs/qrcodejs/master/qrcode.js", + "https://code.jquery.com/ui/1.10.3/jquery-ui.js", + "https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" + ] + for URL in files: + path = urlparse.urlsplit(URL).path + filename = os.path.basename(path) + path = os.path.join(rdir, filename) + if not os.path.exists(path): + print_error("downloading ", URL) + urllib.urlretrieve(URL, path) + + if __name__ == '__main__': import simple_config, util _config = {} @@ -219,6 +243,9 @@ if __name__ == '__main__': if config.get('websocket_server'): import websockets websockets.WebSocketServer(config, server).start() + if config.get('requests_dir'): + check_www_dir(config.get('requests_dir')) + try: daemon_loop(server) except KeyboardInterrupt: diff --git a/lib/wallet.py b/lib/wallet.py @@ -1278,29 +1278,6 @@ class Abstract_Wallet(object): self.receive_requests[key] = req self.storage.put('payment_requests', self.receive_requests) - def check_www_dir(self, config): - import urllib, urlparse, shutil, os - rdir = config.get('requests_dir') - if not os.path.exists(rdir): - os.mkdir(rdir) - index = os.path.join(rdir, 'index.html') - if not os.path.exists(index): - src = os.path.join(os.path.dirname(__file__), 'www', 'index.html') - shutil.copy(src, index) - files = [ - "https://code.jquery.com/jquery-1.9.1.min.js", - "https://raw.githubusercontent.com/davidshimjs/qrcodejs/master/qrcode.js", - "https://code.jquery.com/ui/1.10.3/jquery-ui.js", - "https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" - ] - for URL in files: - path = urlparse.urlsplit(URL).path - filename = os.path.basename(path) - path = os.path.join(rdir, filename) - if not os.path.exists(path): - print_error("downloading ", URL) - urllib.urlretrieve(URL, path) - def add_payment_request(self, req, config): import os @@ -1313,7 +1290,6 @@ class Abstract_Wallet(object): rdir = config.get('requests_dir') if rdir and amount is not None: - self.check_www_dir(config) key = req.get('id', addr) pr = paymentrequest.make_request(config, req) path = os.path.join(rdir, key)