diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6524a3fd7cb85e8093c49e99c381fdbc7c0230c9..1bc87f19a75ebeec1b0f4efc381c15a59272730c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,17 +20,26 @@ stages: before_script: - pip install -e .[dev] +python3.6: + image: python:3.6 + tags: + - passoft + stage: test + script: + - python -m unittest -python2: - image: python:2.7 +python3.7: + image: python:3.7 tags: - passoft stage: test - script: tox -e py27 + script: + - python -m unittest -python3: - image: python:3.6 +python3.8: + image: python:3.8 tags: - passoft stage: test - script: tox -e py36 + script: + - python -m unittest diff --git a/docs/conf.py b/docs/conf.py index 7cb64be32e7e206933ee7be8f23a635e5e8d4838..7571621bb85a6280146838fa2d33858fc7034144 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -47,9 +47,9 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'mseedpeek' -copyright = u"2018, IRIS PASSCAL" -author = u"IRIS PASSCAL" +project = 'mseedpeek' +copyright = "2018, IRIS PASSCAL" +author = "IRIS PASSCAL" # The version info for the project you're documenting, acts as replacement # for |version| and |release|, also used in various other places throughout @@ -129,8 +129,8 @@ latex_elements = { # [howto, manual, or own class]). latex_documents = [ (master_doc, 'mseedpeek.tex', - u'mseedpeek Documentation', - u'IRIS PASSCAL', 'manual'), + 'mseedpeek Documentation', + 'IRIS PASSCAL', 'manual'), ] @@ -140,7 +140,7 @@ latex_documents = [ # (source start file, name, description, authors, manual section). man_pages = [ (master_doc, 'mseedpeek', - u'mseedpeek Documentation', + 'mseedpeek Documentation', [author], 1) ] @@ -152,7 +152,7 @@ man_pages = [ # dir menu entry, description, category) texinfo_documents = [ (master_doc, 'mseedpeek', - u'mseedpeek Documentation', + 'mseedpeek Documentation', author, 'mseedpeek', 'One line description of project.', diff --git a/mseedpeek/libtrace.py b/mseedpeek/libtrace.py index 607547b10c2ce8070941ab7d281fdd737d99365c..bd30878d0ab8c01e6e64589fee424e2f40348a50 100755 --- a/mseedpeek/libtrace.py +++ b/mseedpeek/libtrace.py @@ -114,7 +114,6 @@ # # corrected typo from DHQaul to DHQual # added local variables to class Mseed -from __future__ import (print_function) import os, sys, struct, time SPACE = " " @@ -548,26 +547,35 @@ class Mseed(futils): return 0 ######################################################### - def GetBlk(self, blknum, seekval=0): - ValidBlk=(100,200,201,300,310,320,390,395,400,405,500,1000,1001,2000) - if not blknum in ValidBlk: - return 0 - else: - callcmd="blk=self.blk" + str(blknum) + "(" + str(seekval) + ")" - exec(callcmd) - return blk + + def GetBlk(self, blknum, seekval=0): + ValidBlk = (100, 200, 201, 300, 310, 320, 390, + 395, 400, 405, 500, 1000, 1001, 2000) + if blknum not in ValidBlk: + return 0 + else: + blk = locals() + callcmd = "blk=self.blk" + str(blknum) + "(" + str(seekval) + ")" + exec(callcmd, {}, blk) + return blk + ######################################################### - def PutBlk(self, blknum, indata, endian, seekval=0): - """ - test for valid blockette, if true write blockette - """ - ValidBlk=(100,200,201,300,310,320,390,395,400,405,500,1000,1001,2000) - if not blknum in ValidBlk: - return 0 - else: - callcmd="bytes_written=self.Writeblk" + str(blknum) + "(indata" + "," + str(seekval) + ", endian)" - exec(callcmd) - return bytes_written + + def PutBlk(self, blknum, indata, endian, seekval=0): + """ + test for valid blockette, if true write blockette + """ + ValidBlk = (100, 200, 201, 300, 310, 320, 390, + 395, 400, 405, 500, 1000, 1001, 2000) + if blknum not in ValidBlk: + return 0 + else: + bytes_written = locals() + callcmd = "bytes_written=self.Writeblk" + \ + str(blknum) + "(indata" + "," + str(seekval) + ", endian)" + exec(callcmd, {}, bytes_written) + return bytes_written + ######################################################### def blk100(self, seekval=0): """ diff --git a/mseedpeek/mseedpeek.py b/mseedpeek/mseedpeek.py index 3e7316baf7b2de4f2430f461e035135e7c83f879..63e67a0898d7dbfdbf70dd35a6d1f19032e5d328 100755 --- a/mseedpeek/mseedpeek.py +++ b/mseedpeek/mseedpeek.py @@ -99,28 +99,19 @@ # # Python 3 compatibility # setup.py -from __future__ import print_function import Pmw -try: - from tkinter import * - from tkinter.filedialog import * -except: - from Tkinter import * - from FileDialog import * from os import * from glob import glob from operator import mod from getopt import getopt import sys -try: - from mseedpeek.libtrace import * - from mseedpeek.mseedInfo import * -except: - from libtrace import * - from mseedInfo import * VERSION = "2018.131" +from tkinter import * +from tkinter.filedialog import * +from mseedpeek.libtrace import * +from mseedpeek.mseedInfo import * SPACE = " " def main(): # return version number if -# command line option diff --git a/setup.py b/setup.py index 73eb050bbc1d2a83827d859f9c9a776a3b8767b4..1db522551e6f5a7a3ee6108b98f484167a2a68dc 100644 --- a/setup.py +++ b/setup.py @@ -5,10 +5,10 @@ from setuptools import setup, find_packages -with open('README.rst') as readme_file: +with open('README.rst', 'rt') as readme_file: readme = readme_file.read() -with open('HISTORY.rst') as history_file: +with open('HISTORY.rst', 'rt') as history_file: history = history_file.read() @@ -20,8 +20,9 @@ setup( 'Intended Audience :: Developers', 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', 'Natural Language :: English', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', ], description="View mseed headers", entry_points={ @@ -29,8 +30,8 @@ setup( 'mseedpeek=mseedpeek.mseedpeek:main', ], }, - install_requires=['Pmw'], setup_requires = [], + install_requires=['Pmw @ https://github.com/schrodinger/pmw-patched/archive/master.tar.gz'], extras_require={ 'dev': [ 'pip', diff --git a/tests/test_mseedpeek.py b/tests/test_mseedpeek.py index dfd14574486b63552f5ee1dde68492af944d81d9..df486fd21f33e3a2488d570d97a11a918214c3d9 100644 --- a/tests/test_mseedpeek.py +++ b/tests/test_mseedpeek.py @@ -21,8 +21,4 @@ class TestMseedpeek(unittest.TestCase): """Tear down test fixtures, if any.""" def test_import(self): - if 'mseedpeek' in sys.modules: - self.assert_(True, "mseedpeek loaded") - else: - self.fail() - + self.assertTrue('mseedpeek' in sys.modules, "Mseedpeek import failed!") diff --git a/tox.ini b/tox.ini index 2bc03227b77b4447d3afa7ae230547003790d880..bf6c0725b91a09d47ebc02bcfec374415d4ecfc9 100644 --- a/tox.ini +++ b/tox.ini @@ -1,19 +1,5 @@ [tox] -envlist = py27, py36 flake8 - -[travis] -python = - 2.7: py27 - 3.6: py36 - -[testenv:flake8] -basepython = python -deps = flake8 -commands = flake8 mseedpeek +envlist = py36, py37, py38 [testenv] -setenv = - PYTHONPATH = {toxinidir} -commands=python setup.py test - - +commands = python -m unittest