Skip to content

Commit

Permalink
[cuegui] Kill a Job from Windows. (#1520)
Browse files Browse the repository at this point in the history
**Link the Issue(s) this Pull Request is related to.**
Fixes: #1519

**Summarize your change.**
Use `platform.uname()` instead of `os.uname()`. They have the same
result on Linux, but `os.uname()` is not available on Windows, making us
unable to kill a job from this OS.

**Additional information.**
Linux (ubuntu 22.04.6): 
``` python
>>> os.uname()
posix.uname_result(sysname='Linux', nodename='titan', release='6.8.0-45-generic', version='#45~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Sep 11 15:25:05 UTC 2', machine='x86_64')
>>>platform.uname()
uname_result(system='Linux', node='titan', release='6.8.0-45-generic', version='#45~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Sep 11 15:25:05 UTC 2', machine='x86_64')
```
Windows (11): 
``` python
>>> platform.uname()
uname_result(system='Windows', node='StarChaser', release='10', version='10.0.22631', machine='AMD64')
```
  • Loading branch information
KernAttila authored Oct 1, 2024
1 parent 7e9ae6c commit 8f7f23c
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 11 deletions.
3 changes: 2 additions & 1 deletion pycue/opencue/wrappers/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import getpass
import time
import os
import platform

from opencue import Cuebot
from opencue.compiled_proto import job_pb2
Expand Down Expand Up @@ -75,7 +76,7 @@ def kill(self, username=None, pid=None, host_kill=None, reason=None):
"""Kills the frame."""
username = username if username else getpass.getuser()
pid = pid if pid else os.getpid()
host_kill = host_kill if host_kill else os.uname()[1]
host_kill = host_kill if host_kill else platform.uname()[1]
if self.data.state == job_pb2.FrameState.Value('RUNNING'):
self.stub.Kill(job_pb2.FrameKillRequest(frame=self.data,
username=username,
Expand Down
5 changes: 3 additions & 2 deletions pycue/opencue/wrappers/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import enum
import getpass
import os
import platform
import time

from opencue import Cuebot
Expand Down Expand Up @@ -49,7 +50,7 @@ def kill(self, username=None, pid=None, host_kill=None, reason=None):
"""Kills the job."""
username = username if username else getpass.getuser()
pid = pid if pid else os.getpid()
host_kill = host_kill if host_kill else os.uname()[1]
host_kill = host_kill if host_kill else platform.uname()[1]
self.stub.Kill(job_pb2.JobKillRequest(job=self.data,
username=username,
pid=str(pid),
Expand All @@ -73,7 +74,7 @@ def killFrames(self, username=None, pid=None, host_kill=None, reason=None, **req
"""
username = username if username else getpass.getuser()
pid = pid if pid else os.getpid()
host_kill = host_kill if host_kill else os.uname()[1]
host_kill = host_kill if host_kill else platform.uname()[1]
criteria = opencue.search.FrameSearch.criteriaFromOptions(**request)
self.stub.KillFrames(job_pb2.JobKillFramesRequest(job=self.data,
req=criteria,
Expand Down
3 changes: 2 additions & 1 deletion pycue/opencue/wrappers/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import enum
import getpass
import os
import platform

import opencue.api
from opencue.compiled_proto import job_pb2
Expand Down Expand Up @@ -51,7 +52,7 @@ def kill(self, username=None, pid=None, host_kill=None, reason=None):
"""Kills the entire layer."""
username = username if username else getpass.getuser()
pid = pid if pid else os.getpid()
host_kill = host_kill if host_kill else os.uname()[1]
host_kill = host_kill if host_kill else platform.uname()[1]
return self.stub.KillFrames(job_pb2.LayerKillFramesRequest(layer=self.data,
username=username,
pid=str(pid),
Expand Down
3 changes: 2 additions & 1 deletion pycue/tests/wrappers/frame_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from __future__ import absolute_import
import getpass
import os
import platform
import time
import unittest

Expand Down Expand Up @@ -60,7 +61,7 @@ def testKill(self, getStubMock):
job_pb2.Frame(name=TEST_FRAME_NAME, state=job_pb2.RUNNING))
username = getpass.getuser()
pid = os.getpid()
host_kill = os.uname()[1]
host_kill = platform.uname()[1]
reason = "Frames Kill Request"
frame.kill(username=username, pid=pid, host_kill=host_kill, reason=reason)

Expand Down
5 changes: 3 additions & 2 deletions pycue/tests/wrappers/job_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from __future__ import absolute_import
import getpass
import os
import platform
import unittest

import mock
Expand Down Expand Up @@ -49,7 +50,7 @@ def testKill(self, getStubMock):
job_pb2.Job(name=TEST_JOB_NAME))
username = getpass.getuser()
pid = os.getpid()
host_kill = os.uname()[1]
host_kill = platform.uname()[1]
reason = "Job Kill Request"
job.kill(username=username, pid=pid, host_kill=host_kill, reason=reason)

Expand Down Expand Up @@ -95,7 +96,7 @@ def testKillFrames(self, getStubMock):
job_pb2.Job(name=TEST_JOB_NAME))
username = getpass.getuser()
pid = os.getpid()
host_kill = os.uname()[1]
host_kill = platform.uname()[1]
reason = "Job Kill Request"
job.killFrames(range=frameRange,
username=username,
Expand Down
3 changes: 2 additions & 1 deletion pycue/tests/wrappers/layer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from __future__ import absolute_import
import getpass
import os
import platform
import unittest

import mock
Expand Down Expand Up @@ -49,7 +50,7 @@ def testKill(self, getStubMock):
job_pb2.Layer(name=TEST_LAYER_NAME))
username = getpass.getuser()
pid = os.getpid()
host_kill = os.uname()[1]
host_kill = platform.uname()[1]
reason = "Frames Kill Request"
layer.kill(username=username, pid=pid, host_kill=host_kill, reason=reason)

Expand Down
6 changes: 3 additions & 3 deletions rqd/rqd/rqmachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,11 @@ def __initMachineTags(self):
self.__renderHost.tags.append("windows")
return

if os.uname()[-1] in ("i386", "i686"):
if platform.uname()[-1] in ("i386", "i686"):
self.__renderHost.tags.append("32bit")
elif os.uname()[-1] == "x86_64":
elif platform.uname()[-1] == "x86_64":
self.__renderHost.tags.append("64bit")
self.__renderHost.tags.append(os.uname()[2].replace(".EL.spi", "").replace("smp", ""))
self.__renderHost.tags.append(platform.uname()[2].replace(".EL.spi", "").replace("smp", ""))

def testInitMachineStats(self, pathCpuInfo):
"""Initializes machine stats outside of normal startup process. Used for testing."""
Expand Down

0 comments on commit 8f7f23c

Please sign in to comment.