From 950876f794006f71d8ff10221ea83b05571eddd3 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 7 Apr 2014 15:45:19 +0200 Subject: [PATCH] Removed wget requirement --- Makefile | 8 +++++--- scripts/fetch_from_web.py | 33 +++++++++++++++++++++++++++++++++ setup_environment.sh | 19 +++++++++++++++++++ 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100755 scripts/fetch_from_web.py diff --git a/Makefile b/Makefile index 1d796c07..a28670fe 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,22 @@ WWW_SERVER = http://qmcchem.ups-tlse.fr/files/scemama IRPF90_TGZ = irpf90-latest-noarch-src.tar.gz EZFIO_TGZ = EZFIO.latest.tar.gz +FETCH_FROM_WEB=./scripts/fetch_from_web.py .PHONY: doc src -default: src +default: + ./setup_environment.sh EZFIO: $(info ===== Fetching EZFIO from the web =====) - @wget "$(WWW_SERVER)/$(EZFIO_TGZ)" || \ + @$(FETCH_FROM_WEB) "$(WWW_SERVER)/$(EZFIO_TGZ)" $(EZFIO_TGZ) || \ (echo Unable to download EZFIO : $(WWW_SERVER)/$(EZFIO_TGZ) ; exit 1) @tar -zxf $(EZFIO_TGZ) && rm $(EZFIO_TGZ) irpf90: $(info ===== Fetching IRPF90 from the web =====) - @wget "$(WWW_SERVER)/$(IRPF90_TGZ)" || \ + @$(FETCH_FROM_WEB) "$(WWW_SERVER)/$(IRPF90_TGZ)" $(IRPF90_TGZ) || \ (echo Unable to download IRPF90 : $(WWW_SERVER)/$(IRPF90_TGZ) ; exit 1) @tar -zxf $(IRPF90_TGZ) && rm $(IRPF90_TGZ) $(MAKE) -C irpf90 diff --git a/scripts/fetch_from_web.py b/scripts/fetch_from_web.py new file mode 100755 index 00000000..99cd689c --- /dev/null +++ b/scripts/fetch_from_web.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +import urllib +import sys + +__author__ = "Anthony Scemama" +__date__ = "Mon Apr 7 15:30:29 CEST 2014" + +"""Fetches a file from a given URL. + syntax : %s """%(sys.argv[0]) + +# Check command line +if len(sys.argv) < 3: + print """ + usage: + %s """%(sys.argv[0]) + +URL = sys.argv[1] +filename = sys.argv[2] + + +webpage = urllib.urlopen(URL) +data = webpage.read() + +if "404 - Not Found" in data: + print "Error in URL" + sys.exit(1) + +file = open(filename,'w') +file.write(data) +file.close() + + diff --git a/setup_environment.sh b/setup_environment.sh index cf05d133..1be6688f 100755 --- a/setup_environment.sh +++ b/setup_environment.sh @@ -1,4 +1,8 @@ #!/bin/bash +# +# Setup script. Downloads IRPF90 and EZFIO if they are not already present in the current +# installation. +# Mon Apr 7 15:41:19 CEST 2014 QPACKAGE_ROOT=${PWD} @@ -8,6 +12,11 @@ if [[ -z ${IRPF90} ]] ; then make irpf90 IRPF90=${QPACKAGE_ROOT}/irpf90/bin/irpf90 + if [[ ! -x ${QPACKAGE_ROOT}/irpf90/bin/irpf90 ]] + then + echo "Error in IRPF90 installation" + exit 1 + fi fi cat << EOF > quantum_package.rc @@ -15,7 +24,17 @@ export IRPF90=${IRPF90} export QPACKAGE_ROOT=${QPACKAGE_ROOT} export PATH+=:\${QPACKAGE_ROOT}/scripts export PATH+=:\${QPACKAGE_ROOT}/bin +export QPACKAGE_CACHE_URL="http://qmcchem.ups-tlse.fr/files/scemama/quantum_package/cache/" EOF source quantum_package.rc +if [[ ! -d ${QPACKAGE_ROOT}/EZFIO ]] +then make EZFIO +fi + +if [[ ! -d ${QPACKAGE_ROOT}/EZFIO ]] +then + echo "Error in IRPF90 installation" + exit 1 +fi