Compare commits
2 Commits
2d08fd029d
...
c79e886d77
Author | SHA1 | Date | |
---|---|---|---|
c79e886d77 | |||
76f2d5d972 |
2
PyLoT.py
2
PyLoT.py
@ -1010,7 +1010,7 @@ class MainWindow(QMainWindow):
|
|||||||
events=events)
|
events=events)
|
||||||
if not sld.exec_():
|
if not sld.exec_():
|
||||||
return
|
return
|
||||||
fext = sld.lineEdit.text()
|
fext = sld.comboBox.currentText()
|
||||||
# fext = '.xml'
|
# fext = '.xml'
|
||||||
for event in events:
|
for event in events:
|
||||||
filename = get_pylot_eventfile_with_extension(event, fext)
|
filename = get_pylot_eventfile_with_extension(event, fext)
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
#$ -l low
|
#$ -l low
|
||||||
#$ -cwd
|
#$ -cwd
|
||||||
#$ -pe smp 40
|
#$ -pe smp 40
|
||||||
#$ -l mem=2G
|
##$ -l mem=3G
|
||||||
#$ -l h_vmem=2G
|
#$ -l h_vmem=6G
|
||||||
#$ -l os=*stretch
|
#$ -l os=*stretch
|
||||||
|
|
||||||
conda activate pylot_38
|
conda activate pylot_311
|
||||||
|
|
||||||
python ./autoPyLoT.py -i /home/marcel/.pylot/pylot_adriaarray.in -c 20 -dmt processed
|
python ./autoPyLoT.py -i /home/marcel/.pylot/pylot_adriaarray.in -c 20 -dmt processed
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import glob
|
||||||
import hashlib
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
@ -907,12 +907,25 @@ def get_pylot_eventfile_with_extension(event, fext):
|
|||||||
else:
|
else:
|
||||||
logging.warning('No attribute path found for event.')
|
logging.warning('No attribute path found for event.')
|
||||||
return
|
return
|
||||||
eventname = eventpath.split('/')[-1] # or event.pylot_id
|
eventname = event.pylot_id #path.split('/')[-1] # or event.pylot_id
|
||||||
filename = os.path.join(eventpath, 'PyLoT_' + eventname + fext)
|
filename = os.path.join(eventpath, 'PyLoT_' + eventname + fext)
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
|
|
||||||
|
def get_possible_pylot_eventfile_extensions(event, fext):
|
||||||
|
if hasattr(event, 'path'):
|
||||||
|
eventpath = event.path
|
||||||
|
else:
|
||||||
|
logging.warning('No attribute path found for event.')
|
||||||
|
return []
|
||||||
|
eventname = event.pylot_id
|
||||||
|
filename = os.path.join(eventpath, 'PyLoT_' + eventname + fext)
|
||||||
|
filenames = glob.glob(filename)
|
||||||
|
extensions = [os.path.split(path)[-1].split('PyLoT_' + eventname)[-1] for path in filenames]
|
||||||
|
return extensions
|
||||||
|
|
||||||
|
|
||||||
def get_stations(data):
|
def get_stations(data):
|
||||||
"""
|
"""
|
||||||
Get list of all station names in data stream
|
Get list of all station names in data stream
|
||||||
|
@ -54,7 +54,7 @@ from pylot.core.util.utils import prepTimeAxis, full_range, demeanTrace, isSorte
|
|||||||
check4rotated, check4doubled, check_for_gaps_and_merge, check_for_nan, identifyPhase, \
|
check4rotated, check4doubled, check_for_gaps_and_merge, check_for_nan, identifyPhase, \
|
||||||
loopIdentifyPhase, trim_station_components, transformFilteroptions2String, \
|
loopIdentifyPhase, trim_station_components, transformFilteroptions2String, \
|
||||||
identifyPhaseID, get_bool, get_None, pick_color, getAutoFilteroptions, SetChannelComponents, \
|
identifyPhaseID, get_bool, get_None, pick_color, getAutoFilteroptions, SetChannelComponents, \
|
||||||
station_id_remove_channel, get_pylot_eventfile_with_extension
|
station_id_remove_channel, get_pylot_eventfile_with_extension, get_possible_pylot_eventfile_extensions
|
||||||
from autoPyLoT import autoPyLoT
|
from autoPyLoT import autoPyLoT
|
||||||
from pylot.core.util.thread import Thread
|
from pylot.core.util.thread import Thread
|
||||||
from pylot.core.util.dataprocessing import Metadata
|
from pylot.core.util.dataprocessing import Metadata
|
||||||
@ -1573,12 +1573,14 @@ class SearchFileByExtensionDialog(QtWidgets.QDialog):
|
|||||||
super(SearchFileByExtensionDialog, self).__init__(parent)
|
super(SearchFileByExtensionDialog, self).__init__(parent)
|
||||||
self.events = events
|
self.events = events
|
||||||
self.filepaths = []
|
self.filepaths = []
|
||||||
|
self.file_extensions = []
|
||||||
self.default_text = default_text
|
self.default_text = default_text
|
||||||
self.label = label
|
self.label = label
|
||||||
self.setButtons()
|
self.setButtons()
|
||||||
self.setupUi()
|
self.setupUi()
|
||||||
self.connectSignals()
|
self.connectSignals()
|
||||||
self.showPaths()
|
self.showPaths()
|
||||||
|
self.refreshSelectionBox()
|
||||||
self.refresh_timer = QTimer(self)
|
self.refresh_timer = QTimer(self)
|
||||||
self.refresh_timer.timeout.connect(self.showPaths)
|
self.refresh_timer.timeout.connect(self.showPaths)
|
||||||
self.refresh_timer.start(10000)
|
self.refresh_timer.start(10000)
|
||||||
@ -1594,7 +1596,9 @@ class SearchFileByExtensionDialog(QtWidgets.QDialog):
|
|||||||
|
|
||||||
# widgets inside the dialog
|
# widgets inside the dialog
|
||||||
self.textLabel = QtWidgets.QLabel(self.label)
|
self.textLabel = QtWidgets.QLabel(self.label)
|
||||||
self.lineEdit = QtWidgets.QLineEdit(self.default_text)
|
self.comboBox = QtWidgets.QComboBox()
|
||||||
|
self.comboBox.addItem(self.default_text)
|
||||||
|
self.comboBox.setEditable(True)
|
||||||
|
|
||||||
# optional search button, currently disabled. List refreshed when text changes
|
# optional search button, currently disabled. List refreshed when text changes
|
||||||
self.searchButton = QtWidgets.QPushButton('Search')
|
self.searchButton = QtWidgets.QPushButton('Search')
|
||||||
@ -1614,7 +1618,7 @@ class SearchFileByExtensionDialog(QtWidgets.QDialog):
|
|||||||
self.statusText = QtWidgets.QLabel()
|
self.statusText = QtWidgets.QLabel()
|
||||||
|
|
||||||
self.header_layout.addWidget(self.textLabel)
|
self.header_layout.addWidget(self.textLabel)
|
||||||
self.header_layout.addWidget(self.lineEdit)
|
self.header_layout.addWidget(self.comboBox)
|
||||||
self.header_layout.addWidget(self.searchButton)
|
self.header_layout.addWidget(self.searchButton)
|
||||||
|
|
||||||
self.main_layout.addLayout(self.header_layout)
|
self.main_layout.addLayout(self.header_layout)
|
||||||
@ -1624,7 +1628,7 @@ class SearchFileByExtensionDialog(QtWidgets.QDialog):
|
|||||||
|
|
||||||
def showPaths(self):
|
def showPaths(self):
|
||||||
self.filepaths = []
|
self.filepaths = []
|
||||||
fext = self.lineEdit.text()
|
fext = self.comboBox.currentText()
|
||||||
self.tableWidget.clearContents()
|
self.tableWidget.clearContents()
|
||||||
for index, event in enumerate(self.events):
|
for index, event in enumerate(self.events):
|
||||||
filename = get_pylot_eventfile_with_extension(event, fext)
|
filename = get_pylot_eventfile_with_extension(event, fext)
|
||||||
@ -1634,7 +1638,7 @@ class SearchFileByExtensionDialog(QtWidgets.QDialog):
|
|||||||
ts = int(os.path.getmtime(filename))
|
ts = int(os.path.getmtime(filename))
|
||||||
|
|
||||||
# create QTableWidgetItems of filepath and last modification time
|
# create QTableWidgetItems of filepath and last modification time
|
||||||
fname_item = QtWidgets.QTableWidgetItem(f'{filename}')
|
fname_item = QtWidgets.QTableWidgetItem(f'{os.path.split(filename)[-1]}')
|
||||||
ts_item = QtWidgets.QTableWidgetItem(f'{datetime.datetime.fromtimestamp(ts)}')
|
ts_item = QtWidgets.QTableWidgetItem(f'{datetime.datetime.fromtimestamp(ts)}')
|
||||||
self.tableWidget.setItem(index, 1, fname_item)
|
self.tableWidget.setItem(index, 1, fname_item)
|
||||||
self.tableWidget.setItem(index, 2, ts_item)
|
self.tableWidget.setItem(index, 2, ts_item)
|
||||||
@ -1646,6 +1650,19 @@ class SearchFileByExtensionDialog(QtWidgets.QDialog):
|
|||||||
status_text = 'Did not find any files for specified file mask.'
|
status_text = 'Did not find any files for specified file mask.'
|
||||||
self.statusText.setText(status_text)
|
self.statusText.setText(status_text)
|
||||||
|
|
||||||
|
def refreshSelectionBox(self):
|
||||||
|
fext = self.comboBox.currentText()
|
||||||
|
self.file_extensions = [fext]
|
||||||
|
|
||||||
|
for event in self.events:
|
||||||
|
extensions = get_possible_pylot_eventfile_extensions(event, '*.xml')
|
||||||
|
for ext in extensions:
|
||||||
|
if not ext in self.file_extensions:
|
||||||
|
self.file_extensions.append(ext)
|
||||||
|
|
||||||
|
self.comboBox.clear()
|
||||||
|
for ext in sorted(self.file_extensions):
|
||||||
|
self.comboBox.addItem(ext)
|
||||||
|
|
||||||
def setButtons(self):
|
def setButtons(self):
|
||||||
self._buttonbox = QDialogButtonBox(QDialogButtonBox.Ok |
|
self._buttonbox = QDialogButtonBox(QDialogButtonBox.Ok |
|
||||||
@ -1654,7 +1671,7 @@ class SearchFileByExtensionDialog(QtWidgets.QDialog):
|
|||||||
def connectSignals(self):
|
def connectSignals(self):
|
||||||
self._buttonbox.accepted.connect(self.accept)
|
self._buttonbox.accepted.connect(self.accept)
|
||||||
self._buttonbox.rejected.connect(self.reject)
|
self._buttonbox.rejected.connect(self.reject)
|
||||||
self.lineEdit.textChanged.connect(self.showPaths)
|
self.comboBox.editTextChanged.connect(self.showPaths)
|
||||||
self.searchButton.clicked.connect(self.showPaths)
|
self.searchButton.clicked.connect(self.showPaths)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user