nodeocc 1.0.11__tar.gz → 1.0.12__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. {nodeocc-1.0.11 → nodeocc-1.0.12}/PKG-INFO +1 -1
  2. {nodeocc-1.0.11 → nodeocc-1.0.12}/pyproject.toml +1 -1
  3. {nodeocc-1.0.11 → nodeocc-1.0.12}/src/nodeocc.egg-info/PKG-INFO +1 -1
  4. {nodeocc-1.0.11 → nodeocc-1.0.12}/src/view/curses_multiwindow.py +28 -6
  5. {nodeocc-1.0.11 → nodeocc-1.0.12}/README.md +0 -0
  6. {nodeocc-1.0.11 → nodeocc-1.0.12}/setup.cfg +0 -0
  7. {nodeocc-1.0.11 → nodeocc-1.0.12}/setup.py +0 -0
  8. {nodeocc-1.0.11 → nodeocc-1.0.12}/src/__init__.py +0 -0
  9. {nodeocc-1.0.11 → nodeocc-1.0.12}/src/controller/controller.py +0 -0
  10. {nodeocc-1.0.11 → nodeocc-1.0.12}/src/model/infrastructure.py +0 -0
  11. {nodeocc-1.0.11 → nodeocc-1.0.12}/src/model/job.py +0 -0
  12. {nodeocc-1.0.11 → nodeocc-1.0.12}/src/nodeocc.egg-info/SOURCES.txt +0 -0
  13. {nodeocc-1.0.11 → nodeocc-1.0.12}/src/nodeocc.egg-info/dependency_links.txt +0 -0
  14. {nodeocc-1.0.11 → nodeocc-1.0.12}/src/nodeocc.egg-info/entry_points.txt +0 -0
  15. {nodeocc-1.0.11 → nodeocc-1.0.12}/src/nodeocc.egg-info/requires.txt +0 -0
  16. {nodeocc-1.0.11 → nodeocc-1.0.12}/src/nodeocc.egg-info/top_level.txt +0 -0
  17. {nodeocc-1.0.11 → nodeocc-1.0.12}/src/readers/compute_wait_time.py +0 -0
  18. {nodeocc-1.0.11 → nodeocc-1.0.12}/src/readers/slurmreader.py +0 -0
  19. {nodeocc-1.0.11 → nodeocc-1.0.12}/src/view/__init__.py +0 -0
  20. {nodeocc-1.0.11 → nodeocc-1.0.12}/src/view/slurm_list.py +0 -0
  21. {nodeocc-1.0.11 → nodeocc-1.0.12}/src/view/slurm_viz.py +0 -0
  22. {nodeocc-1.0.11 → nodeocc-1.0.12}/src/view/styles.py +0 -0
  23. {nodeocc-1.0.11 → nodeocc-1.0.12}/src/view/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nodeocc
3
- Version: 1.0.11
3
+ Version: 1.0.12
4
4
  Summary: TUI application for viewing the status of GPU allocations on a Slurm cluster
5
5
  Author: Matteo Boschini
6
6
  Maintainer: Lorenzo Bonicelli, Aniello Panariello
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "nodeocc"
7
- version = "1.0.11"
7
+ version = "1.0.12"
8
8
  authors = [{ name = "Matteo Boschini" }]
9
9
  maintainers = [{ name = "Lorenzo Bonicelli" }, { name = "Aniello Panariello" }]
10
10
  description = "TUI application for viewing the status of GPU allocations on a Slurm cluster"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nodeocc
3
- Version: 1.0.11
3
+ Version: 1.0.12
4
4
  Summary: TUI application for viewing the status of GPU allocations on a Slurm cluster
5
5
  Author: Matteo Boschini
6
6
  Maintainer: Lorenzo Bonicelli, Aniello Panariello
@@ -13,6 +13,7 @@ import traceback
13
13
  from logging.handlers import RotatingFileHandler
14
14
  from pathlib import Path
15
15
  from view import update_views
16
+ import stat
16
17
 
17
18
  a_filter_values = [None, 'me', 'prod', 'stud', 'cvcs']
18
19
 
@@ -35,6 +36,14 @@ BUTTON_ACTIONS = {
35
36
  }
36
37
 
37
38
 
39
+ def is_file_writable_byall(file_path):
40
+ return os.stat(file_path).st_mode & stat.S_IWOTH
41
+
42
+
43
+ def is_file_readable_byall(file_path):
44
+ return os.stat(file_path).st_mode & stat.S_IROTH
45
+
46
+
38
47
  def try_open_socket_as_slave(instance):
39
48
  if not instance.port_file_exists():
40
49
  raise Exception("No master running")
@@ -89,7 +98,7 @@ class Singleton:
89
98
 
90
99
  def clean_port_files(self):
91
100
  for f in os.listdir(self.basepath):
92
- if f.endswith('.port'):
101
+ if f.endswith('.port') and is_file_writable_byall(os.path.join(self.basepath, f)):
93
102
  os.system(f"rm {os.path.join(self.basepath, f)}")
94
103
 
95
104
  def __init__(self, args=None):
@@ -158,8 +167,11 @@ class Singleton:
158
167
 
159
168
  def get_port_file_name(self):
160
169
  if self.port_file_exists():
161
- fname = [f for f in os.listdir(self.basepath) if f.endswith('.port')][0]
162
- return fname, os.path.join(self.basepath, fname)
170
+ portfiles = [f for f in os.listdir(self.basepath) if f.endswith('.port')]
171
+ portfiles = [(f, os.path.join(self.basepath, f)) for f in portfiles]
172
+ portfiles = [(fname, fpath) for fname, fpath in portfiles if is_file_readable_byall(fpath) and is_file_writable_byall(fpath)][0]
173
+
174
+ return portfiles[0], portfiles[1]
163
175
  return None
164
176
 
165
177
  def check_existing_master_running(self):
@@ -171,7 +183,15 @@ class Singleton:
171
183
  return False
172
184
 
173
185
  def port_file_exists(self):
174
- return len([f for f in os.listdir(self.basepath) if f.endswith('.port')]) > 0
186
+ """
187
+ Check if a port file exists in the basepath and the file has 666 permissions
188
+ """
189
+ portfiles = [f for f in os.listdir(self.basepath) if f.endswith('.port')]
190
+ if len(portfiles) == 0:
191
+ return False
192
+ portfiles = [os.path.join(self.basepath, f) for f in portfiles]
193
+ portfiles = [f for f in portfiles if is_file_readable_byall(f) and is_file_writable_byall(f)]
194
+ return len(portfiles) > 0
175
195
 
176
196
  def create_socket_as_master(self):
177
197
  # create udp socket for broadcasting
@@ -191,8 +211,10 @@ class Singleton:
191
211
  # get pid of current process
192
212
  self.pid = os.getpid()
193
213
 
194
- # create file to store port
195
- Path(self.basepath, f'{self.port}.port').write_text(str(self.pid))
214
+ # create file to store port with 666 permissions to file
215
+ filepath = Path(self.basepath, f'{self.port}.port')
216
+ filepath.write_text(str(self.pid))
217
+ os.chmod(filepath, 0o666)
196
218
 
197
219
  return self.port
198
220
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes