Skip to content

Commit

Permalink
Created an install script that would download hapiest and install it'…
Browse files Browse the repository at this point in the history
…s dependencies, as long as python3 is in the path. There are also two launch scripts that require that python3 is named python
  • Loading branch information
jkarns275 committed Dec 9, 2017
1 parent 71ce132 commit dad6936
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 9 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# hapiest
*hapiest* is (going to be) a GUI that works with the HITRAN API, enabling access
*hapiest* is a GUI that works with the HITRAN API, enabling access
to all sorts of spectrographic data without knowledge of python.

# How to Run

# References
R.V. Kochanov, I.E. Gordon, L.S. Rothman, P. Wcislo, C. Hill, J.S. Wilzewski, HITRAN Application Programming Interface (HAPI): A comprehensive approach to working with spectroscopic data, J. Quant. Spectrosc. Radiat. Transfer 177, 15-30 (2016) [http://www.sciencedirect.com/science/article/pii/S0022407315302466?via%3Dihub].
69 changes: 69 additions & 0 deletions install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env python

import sys

if sys.version_info[0] < 3:
print('You must have Python 3 installed to use hapiest - current version is ' + str(sys.version))
raw_input('Hit enter to continue')
sys.exit(0)

REQUIREMENTS = ['PyQt5', 'PyQtChart', 'toml', 'parsy']

try:
import PyQt5
import PyQt5.QtChart
import toml
import parsy

print('All required packages are already installed!')
except:
import os, pip

pip_args = ['-vvv']
if 'http_proxy' in os.environ:
proxy = os.environ['http_proxy']
pip_args.append('--proxy')
pip_args.append(proxy)

pip_args.append('install')
for req in REQUIREMENTS:
pip_args.append(req)
print('Installing requirements: ' + str(REQUIREMENTS))
pip.main(pip_args)

try:
import PyQt5
import PyQt5.QtChart
import toml
import parsy

print('\n\n\n\nSuccessfully installed all missing packages')
except:
print('Failed to install all requirements :(')
print('Try installing the requirements manually')
input('Hit enter to continue')
sys.exit(0)

finally:
from urllib.request import urlretrieve

try:
response = urlretrieve('https://github.com/hapiest-team/hapiest/archive/master.zip', 'hapiest.zip')
except Exception as e:
print('Encountered error \'' + str(e) + '\' while trying to download hapiest.')
input('Hit enter to continue')
sys.exit(0)
finally:
import zipfile

try:
zip = zipfile.ZipFile('hapiest.zip', 'r')
zip.extractall('hapiest')
zip.close()
print('Hapiest has successfully been installed in the directory \'hapiest\'')
except Exception as e:
print('Encountered error \'' + str(e) + '\' when attempting to extract hapiest.zip')
input('Hit enter to continue')
sys.exit(0)

input('Hit enter to continue')
2 changes: 2 additions & 0 deletions run
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
python src/__main__.py
3 changes: 3 additions & 0 deletions run.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo on
python src/__main__.py
@echo off
8 changes: 4 additions & 4 deletions src/hapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3887,7 +3887,7 @@ def __init__(self, arg1):
# Exception didn't occur, we're good.
pass
finally:
# This is executed after the code block is run
# This is executed after the code block is install.py
# and all exceptions have been handled, even
# if a new exception is raised while handling.
print "We're done with that."
Expand Down Expand Up @@ -4599,7 +4599,7 @@ def print_data_tutorial():
# get data on CO2 main isotopologue in the range 2000-2100 cm-1
>>> fetch('CO2',2,1,2000,2100)

OK, now we're ready to run a fast example of how to calculate an
OK, now we're ready to install.py a fast example of how to calculate an
absorption coefficient cross section:

>>> nu,coef = absorptionCoefficient_Lorentz(SourceTables='CO2')
Expand Down Expand Up @@ -4911,8 +4911,8 @@ def print_spectra_tutorial():
Matplotlib can be obtained by the link http://matplotlib.org/
2) Numpy (required by HAPI itself)
Numpy can be obtained via pip:
sudo pip install numpy (under Linux and Mac)
pip install numpy (under Windows)
sudo pip install.py numpy (under Linux and Mac)
pip install.py numpy (under Windows)
Or by the link http://www.numpy.org/

As an option, user can download one of the many scientific Python
Expand Down
2 changes: 1 addition & 1 deletion src/utils/console_redirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def init_console_redirect(main_window, *args, **kwargs):
TextReceiver.WINDOW = main_window
# Create a receiver
TextReceiver.TEXT_RECEIVER = TextReceiver(TextReceiver.TEXT_EDIT_STREAM.queue, *args, **kwargs)
# Create a thread for the receiver to run in
# Create a thread for the receiver to install.py in
TextReceiver.TEXT_THREAD = QtCore.QThread()
# Connect the signal to the console output handler in the main window
# Connect the console output signals
Expand Down
6 changes: 3 additions & 3 deletions src/widgets/main_window_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def __on_select_table_name_complete(self, work_result):

def __on_run_button_click(self):
"""
*Tries to run the select function*
*Tries to install.py the select function*
"""
self.clear_select_error()

Expand Down Expand Up @@ -507,7 +507,7 @@ def __on_run_done(self, work_result):

def __on_output_name_change(self):
"""
*When the output name changes, if it is empty, display a warning and disable the run button - otherwise enable it.*
*When the output name changes, if it is empty, display a warning and disable the install.py button - otherwise enable it.*
"""
try:
output_name = self.output_name.text()
Expand All @@ -527,7 +527,7 @@ def __on_output_name_change(self):

def __on_conditions_finished_editing(self):
"""
*When the conditions are changed, make sure they are valid - if they're not, disable the run button
*When the conditions are changed, make sure they are valid - if they're not, disable the install.py button
and display a warning..*
"""
expression = self.get_select_expression()
Expand Down

0 comments on commit dad6936

Please sign in to comment.