Changeset 4482 for palm/trunk/SCRIPTS
- Timestamp:
- Apr 1, 2020 1:17:50 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SCRIPTS/palmrungui
r4481 r4482 25 25 # ----------------- 26 26 # $Id$ 27 # Added possibility to delete all files in a directory and option to create 28 # blank new jobs 29 # 30 # 4481 2020-03-31 18:55:54Z maronga 27 31 # Bugfixes: - reading history lines discard button caused error message 28 32 # - deleting of USER_CODE files did not work … … 1263 1267 self.change_commandline("a","") 1264 1268 1269 # Create a new (empty) job 1270 def create_new_job(self): 1271 1272 self.setEnabled(False) 1273 1274 text, ret = QtGui.QInputDialog.getText(self, "Create new job", "Enter new job name:", mode = QtGui.QLineEdit.Normal, text = '') 1275 1276 if ( ret ): 1277 new_job_name = str(text) 1278 else: 1279 self.setEnabled(True) 1280 return 1281 1282 new_input_dir = job_dir + "/" + new_job_name + "/INPUT" 1283 1284 # check if a job exists with the new job name. If not, the new job is created and an empty _p3d file is created. 1285 if ( os.path.isdir(new_input_dir) ): 1286 notify = QtGui.QMessageBox.warning(self,'Create new job directory',"Error. Could not create job directory. A job with the new name already exists.") 1287 self.setEnabled(True) 1288 return 1289 else: 1290 os.makedirs(new_input_dir) 1291 os.mknod(new_input_dir + '/' + new_job_name + '_p3d') 1292 1293 # write default namelists into _p3d file 1294 filename = open(new_input_dir + '/' + new_job_name + '_p3d', "w") 1295 filename.write('&initialization_parameters\n nx = 39,\n ny = 39,\n nz = 40,\n dx = 50.0,\n dy = 50.0,\n dz = 50.0,\n/\n\n') 1296 filename.write('&runtime_parameters\n end_time = 3600.0,\n/\n') 1297 filename.close() 1298 1299 1300 # create empty USER_CODE folder for convenience 1301 new_user_dir = job_dir + "/" + new_job_name + "/USER_CODE" 1302 os.makedirs(new_user_dir) 1303 1304 1305 self.load_jobs() 1306 self.list_input.clear() 1307 self.list_user.clear() 1308 self.list_monitoring.clear() 1309 self.list_output.clear() 1310 self.setEnabled(True) 1311 1312 1265 1313 # Make a copy of a job 1266 1314 def copy_job(self): … … 1293 1341 1294 1342 list_of_files = os.listdir(job_to_copy) 1295 1343 1296 1344 for i in range(0,len(list_of_files)): 1297 1345 … … 1304 1352 1305 1353 new_user_dir = job_dir + "/" + new_job_name + "/USER_CODE" 1306 1354 1307 1355 # check if user code exists in the new job directory 1308 1356 if ( os.path.isdir(new_user_dir) ): … … 1417 1465 menu = QtGui.QMenu() 1418 1466 1467 1468 newAction = QtGui.QAction('Create new job', self) 1469 newAction.triggered.connect(self.create_new_job) 1470 menu.addAction(newAction) 1419 1471 selection = self.list_jobs.selectedItems() 1420 1472 1421 1473 if ( len(selection) != 0 ): 1474 1422 1475 1423 1476 copyAction = QtGui.QAction('Copy job', self) … … 1432 1485 menu.addAction(delAction) 1433 1486 1434 action = menu.exec_(self.list_jobs.mapToGlobal(position)) 1435 1436 1487 action = menu.exec_(self.list_jobs.mapToGlobal(position)) 1488 1437 1489 # Add a custom context menu 1438 1490 def openmenuinput(self, position): … … 1450 1502 1451 1503 1452 delAction = QtGui.QAction('Delete file(s)', self)1504 delAction = QtGui.QAction('Delete selected file(s)', self) 1453 1505 delAction.triggered.connect(self.DeleteFilesInput) 1454 1506 … … 1456 1508 menu.addAction(delAction) 1457 1509 1458 action = menu.exec_(self.list_input.mapToGlobal(position)) 1510 delallAction = QtGui.QAction('Delete all files', self) 1511 delallAction.triggered.connect(self.DeleteAllFilesInput) 1512 menu.addAction(delallAction) 1513 1514 action = menu.exec_(self.list_input.mapToGlobal(position)) 1459 1515 1460 1516 # Add a custom context menu … … 1477 1533 menu.addAction(openAction) 1478 1534 menu.addAction(delAction) 1479 action = menu.exec_(self.list_user.mapToGlobal(position)) 1535 1536 delallAction = QtGui.QAction('Delete all files', self) 1537 delallAction.triggered.connect(self.DeleteAllFilesUser) 1538 menu.addAction(delallAction) 1539 1540 action = menu.exec_(self.list_user.mapToGlobal(position)) 1480 1541 1481 1542 # Add a custom context menu … … 1485 1546 1486 1547 selection = self.list_output.selectedItems() 1487 1548 1488 1549 if ( len(selection) != 0 ): 1489 1550 … … 1492 1553 openAction.triggered.connect(self.OpenFilesOutput) 1493 1554 1494 1495 1555 delAction = QtGui.QAction('Delete file(s)', self) 1496 1556 delAction.triggered.connect(self.DeleteFilesOutput) 1497 1557 1558 1559 1498 1560 menu.addAction(openAction) 1499 1561 menu.addAction(delAction) 1500 action = menu.exec_(self.list_output.mapToGlobal(position)) 1562 1563 delallAction = QtGui.QAction('Delete all files', self) 1564 delallAction.triggered.connect(self.DeleteAllFilesOutput) 1565 menu.addAction(delallAction) 1566 1567 action = menu.exec_(self.list_output.mapToGlobal(position)) 1501 1568 1502 1569 # Add a custom context menu … … 1513 1580 openAction.triggered.connect(self.OpenFilesMonitoring) 1514 1581 1515 1516 1582 delAction = QtGui.QAction('Delete file(s)', self) 1517 1583 delAction.triggered.connect(self.DeleteFilesMonitoring) 1518 1584 1585 1586 1519 1587 menu.addAction(openAction) 1520 1588 menu.addAction(delAction) 1521 action = menu.exec_(self.list_monitoring.mapToGlobal(position)) 1589 1590 delallAction = QtGui.QAction('Delete all files', self) 1591 delallAction.triggered.connect(self.DeleteAllFilesMonitoring) 1592 menu.addAction(delallAction) 1593 1594 action = menu.exec_(self.list_monitoring.mapToGlobal(position)) 1522 1595 1523 1596 def OpenConfig(self): … … 1655 1728 self.update_all() 1656 1729 1730 1731 def DeleteAllFilesInput(self): 1732 1733 status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete all files?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) 1734 1735 if status == QtGui.QMessageBox.Yes: 1736 1737 check = self.list_jobs.currentItem() 1738 if ( check ): 1739 sel_job = self.list_jobs.currentItem().text() 1740 sel_files = self.list_input.selectedItems() 1741 1742 input_dir = job_dir + "/" + sel_job + "/INPUT/" 1743 1744 if os.path.exists(str(input_dir)): 1745 shutil.rmtree(str(input_dir)) 1746 os.makedirs(str(input_dir)) 1747 1748 self.update_all() 1749 1750 1751 def DeleteAllFilesUser(self): 1752 1753 status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete all files?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) 1754 1755 if status == QtGui.QMessageBox.Yes: 1756 1757 check = self.list_jobs.currentItem() 1758 if ( check ): 1759 sel_job = self.list_jobs.currentItem().text() 1760 sel_files = self.list_input.selectedItems() 1761 1762 input_dir = job_dir + "/" + sel_job + "/USER_CODE/" 1763 1764 if os.path.exists(str(input_dir)): 1765 shutil.rmtree(str(input_dir)) 1766 os.makedirs(str(input_dir)) 1767 1768 self.update_all() 1769 1770 1771 1772 def DeleteAllFilesOutput(self): 1773 1774 status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete all files?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) 1775 1776 if status == QtGui.QMessageBox.Yes: 1777 1778 check = self.list_jobs.currentItem() 1779 if ( check ): 1780 sel_job = self.list_jobs.currentItem().text() 1781 sel_files = self.list_input.selectedItems() 1782 1783 input_dir = job_dir + "/" + sel_job + "/OUTPUT/" 1784 1785 if os.path.exists(str(input_dir)): 1786 shutil.rmtree(str(input_dir)) 1787 os.makedirs(str(input_dir)) 1788 1789 self.update_all() 1790 1791 1792 1793 def DeleteAllFilesMonitoring(self): 1794 1795 status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete all files?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) 1796 1797 if status == QtGui.QMessageBox.Yes: 1798 1799 check = self.list_jobs.currentItem() 1800 if ( check ): 1801 sel_job = self.list_jobs.currentItem().text() 1802 sel_files = self.list_input.selectedItems() 1803 1804 input_dir = job_dir + "/" + sel_job + "/MONITORING/" 1805 1806 if os.path.exists(str(input_dir)): 1807 shutil.rmtree(str(input_dir)) 1808 os.makedirs(str(input_dir)) 1809 1810 self.update_all() 1811 1812 1813 1657 1814 def DeleteJob(self): 1658 1815
Note: See TracChangeset
for help on using the changeset viewer.