Skip to content
Snippets Groups Projects
Commit f98a9ff3 authored by Maeva Pourpoint's avatar Maeva Pourpoint
Browse files

Updated and tested data2passcal to work with Python 2 and 3

parent 041dd010
No related branches found
No related tags found
1 merge request!3Python 2/3 compatibility
Pipeline #677 passed with stage
in 1 minute and 10 seconds
...@@ -10,3 +10,10 @@ History ...@@ -10,3 +10,10 @@ History
2018.228 (2018-08-16) 2018.228 (2018-08-16)
------------------ ------------------
* Updated to work with python 2 and 3 * Updated to work with python 2 and 3
2020.093 (2020-04-02)
------------------
* Updated to work with python 2 and 3.
* Resources used: Python-Future project and Futurize tool.
* Changes tested using unittest module on individual test methods(tests.test_data2passcal)
* Changes tested against real seismic dataset (AB.2002 - 2012)
...@@ -4,6 +4,7 @@ data2passcal ...@@ -4,6 +4,7 @@ data2passcal
Prepare SEED data for shipment to PASSCAL. Prepare SEED data for shipment to PASSCAL.
Only accept day-long MSEED files.
* Free software: GNU General Public License v3 (GPLv3) * Free software: GNU General Public License v3 (GPLv3)
......
...@@ -4,4 +4,4 @@ ...@@ -4,4 +4,4 @@
__author__ = """IRIS PASSCAL""" __author__ = """IRIS PASSCAL"""
__email__ = 'software-support@passcal.nmt.edu' __email__ = 'software-support@passcal.nmt.edu'
__version__ = '2018.228' __version__ = '2020.093'
...@@ -5,8 +5,9 @@ data2passcal ...@@ -5,8 +5,9 @@ data2passcal
Ship miniseed data to passcal via ftp for qc before archival at DMC DMS Ship miniseed data to passcal via ftp for qc before archival at DMC DMS
Lloyd Carothers IRIS/PASSCAL Lloyd Carothers IRIS/PASSCAL
''' '''
from __future__ import print_function from __future__ import print_function, division
VERSION = '2018.228' from builtins import *
VERSION = '2020.093'
import ftplib import ftplib
import sys, os, signal, struct, pickle, logging import sys, os, signal, struct, pickle, logging
...@@ -313,11 +314,11 @@ def send2passcal(mslist, sentlist=None): ...@@ -313,11 +314,11 @@ def send2passcal(mslist, sentlist=None):
update.bytes_sent += len(data) update.bytes_sent += len(data)
print('\r' + str(PB) + ' %s /sec ' % ( format_size(size_sent / (time() - starttime )) ), end=' ') print('\r' + str(PB) + ' %s /sec ' % ( format_size(size_sent / (time() - starttime )) ), end=' ')
''' '''
print '%s %0.2f%%. %0.10d / %0.10d.' % ( current_file.center(20), print '%s %0.2f%%. %0.10d / %0.10d.' % ( current_file.center(20),
(update.bytes_sent / update.file_size)*100, (update.bytes_sent / update.file_size)*100,
update.bytes_sent, update.bytes_sent,
file_size, file_size,
) , ) ,
''' '''
ETA_sec = ((time() - starttime) / size_sent ) * (size_to_send - size_sent) ETA_sec = ((time() - starttime) / size_sent ) * (size_to_send - size_sent)
print('ETA %s %s %s' % ( str(datetime.timedelta(seconds=(ETA_sec))), current_file.center(20), ' '*20 ), end=' ') print('ETA %s %s %s' % ( str(datetime.timedelta(seconds=(ETA_sec))), current_file.center(20), ' '*20 ), end=' ')
...@@ -388,7 +389,7 @@ def send2passcal(mslist, sentlist=None): ...@@ -388,7 +389,7 @@ def send2passcal(mslist, sentlist=None):
######################################################## ########################################################
# From progressbar 3rd party class will eventually dump not awesome # From progressbar 3rd party class will eventually dump not awesome
class ProgressBar: class ProgressBar(object):
def __init__(self, duration): def __init__(self, duration):
self.duration = duration self.duration = duration
self.prog_bar = '[]' self.prog_bar = '[]'
......
[bumpversion] [bumpversion]
current_version = 2018.228 current_version = 2020.093
commit = True commit = True
tag = True tag = True
...@@ -19,4 +19,3 @@ exclude = docs ...@@ -19,4 +19,3 @@ exclude = docs
[aliases] [aliases]
# Define setup.py command aliases here # Define setup.py command aliases here
...@@ -52,6 +52,6 @@ setup( ...@@ -52,6 +52,6 @@ setup(
packages=find_packages(include=['data2passcal']), packages=find_packages(include=['data2passcal']),
test_suite='tests', test_suite='tests',
url='https://git.passcal.nmt.edu/passoft/data2passcal', url='https://git.passcal.nmt.edu/passoft/data2passcal',
version='2018.228', version='2020.093',
zip_safe=False, zip_safe=False,
) )
...@@ -22,7 +22,6 @@ class TestData2passcal(unittest.TestCase): ...@@ -22,7 +22,6 @@ class TestData2passcal(unittest.TestCase):
def test_import(self): def test_import(self):
if 'data2passcal' in sys.modules: if 'data2passcal' in sys.modules:
self.assert_(True, "data2passcal loaded") self.assertTrue(True, "data2passcal loaded")
else: else:
self.fail() self.fail()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment