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)
|
||||
if not sld.exec_():
|
||||
return
|
||||
fext = sld.lineEdit.text()
|
||||
fext = sld.comboBox.currentText()
|
||||
# fext = '.xml'
|
||||
for event in events:
|
||||
filename = get_pylot_eventfile_with_extension(event, fext)
|
||||
|
@ -3,10 +3,10 @@
|
||||
#$ -l low
|
||||
#$ -cwd
|
||||
#$ -pe smp 40
|
||||
#$ -l mem=2G
|
||||
#$ -l h_vmem=2G
|
||||
##$ -l mem=3G
|
||||
#$ -l h_vmem=6G
|
||||
#$ -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
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import glob
|
||||
import hashlib
|
||||
import logging
|
||||
import os
|
||||
@ -907,12 +907,25 @@ def get_pylot_eventfile_with_extension(event, fext):
|
||||
else:
|
||||
logging.warning('No attribute path found for event.')
|
||||
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)
|
||||
if os.path.isfile(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):
|
||||
"""
|
||||
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, \
|
||||
loopIdentifyPhase, trim_station_components, transformFilteroptions2String, \
|
||||
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 pylot.core.util.thread import Thread
|
||||
from pylot.core.util.dataprocessing import Metadata
|
||||
@ -1573,12 +1573,14 @@ class SearchFileByExtensionDialog(QtWidgets.QDialog):
|
||||
super(SearchFileByExtensionDialog, self).__init__(parent)
|
||||
self.events = events
|
||||
self.filepaths = []
|
||||
self.file_extensions = []
|
||||
self.default_text = default_text
|
||||
self.label = label
|
||||
self.setButtons()
|
||||
self.setupUi()
|
||||
self.connectSignals()
|
||||
self.showPaths()
|
||||
self.refreshSelectionBox()
|
||||
self.refresh_timer = QTimer(self)
|
||||
self.refresh_timer.timeout.connect(self.showPaths)
|
||||
self.refresh_timer.start(10000)
|
||||
@ -1594,7 +1596,9 @@ class SearchFileByExtensionDialog(QtWidgets.QDialog):
|
||||
|
||||
# widgets inside the dialog
|
||||
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
|
||||
self.searchButton = QtWidgets.QPushButton('Search')
|
||||
@ -1614,7 +1618,7 @@ class SearchFileByExtensionDialog(QtWidgets.QDialog):
|
||||
self.statusText = QtWidgets.QLabel()
|
||||
|
||||
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.main_layout.addLayout(self.header_layout)
|
||||
@ -1624,7 +1628,7 @@ class SearchFileByExtensionDialog(QtWidgets.QDialog):
|
||||
|
||||
def showPaths(self):
|
||||
self.filepaths = []
|
||||
fext = self.lineEdit.text()
|
||||
fext = self.comboBox.currentText()
|
||||
self.tableWidget.clearContents()
|
||||
for index, event in enumerate(self.events):
|
||||
filename = get_pylot_eventfile_with_extension(event, fext)
|
||||
@ -1634,7 +1638,7 @@ class SearchFileByExtensionDialog(QtWidgets.QDialog):
|
||||
ts = int(os.path.getmtime(filename))
|
||||
|
||||
# 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)}')
|
||||
self.tableWidget.setItem(index, 1, fname_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.'
|
||||
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):
|
||||
self._buttonbox = QDialogButtonBox(QDialogButtonBox.Ok |
|
||||
@ -1654,7 +1671,7 @@ class SearchFileByExtensionDialog(QtWidgets.QDialog):
|
||||
def connectSignals(self):
|
||||
self._buttonbox.accepted.connect(self.accept)
|
||||
self._buttonbox.rejected.connect(self.reject)
|
||||
self.lineEdit.textChanged.connect(self.showPaths)
|
||||
self.comboBox.editTextChanged.connect(self.showPaths)
|
||||
self.searchButton.clicked.connect(self.showPaths)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user