Coverage for python / lsst / ctrl / execute / qCommand.py: 0%

26 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-05-06 08:41 +0000

1# This file is part of ctrl_execute. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# This software is dual licensed under the GNU General Public License and also 

10# under a 3-clause BSD license. Recipients may choose which of these licenses 

11# to use; please see the files gpl-3.0.txt and/or bsd_license.txt, 

12# respectively. If you choose the GPL option then the following text applies 

13# (but note that there is still no warranty even if you opt for BSD instead): 

14# 

15# This program is free software: you can redistribute it and/or modify 

16# it under the terms of the GNU General Public License as published by 

17# the Free Software Foundation, either version 3 of the License, or 

18# (at your option) any later version. 

19# 

20# This program is distributed in the hope that it will be useful, 

21# but WITHOUT ANY WARRANTY; without even the implied warranty of 

22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

23# GNU General Public License for more details. 

24# 

25# You should have received a copy of the GNU General Public License 

26# along with this program. If not, see <https://www.gnu.org/licenses/>. 

27 

28import os 

29import os.path 

30 

31from lsst.ctrl.execute.allocationConfig import AllocationConfig 

32from lsst.ctrl.execute.condorInfoConfig import CondorInfoConfig 

33from lsst.ctrl.execute.findPackageFile import find_package_file 

34 

35 

36class QCommand: 

37 """A class which wraps qsub-style commands for execution""" 

38 

39 def __init__(self, platform: str): 

40 # can handle both grid-proxy and ssh logins 

41 self.remoteLoginCmd = "/usr/bin/gsissh" 

42 

43 # can handle both grid-proxy and ssh copies 

44 self.remoteCopyCmd = "/usr/bin/gsiscp" 

45 

46 configFileName = find_package_file("condor-info.py") 

47 

48 condorInfoConfig = CondorInfoConfig() 

49 condorInfoConfig.load(configFileName) 

50 

51 configName = find_package_file("pbsConfig.py", platform=platform) 

52 

53 allocationConfig = AllocationConfig() 

54 allocationConfig.load(configName) 

55 

56 self.userName = condorInfoConfig.platform[platform].user.name 

57 

58 self.hostName = allocationConfig.platform.loginHostName 

59 self.utilityPath = allocationConfig.platform.utilityPath 

60 

61 def runCommand(self, command): 

62 """Execute the command line""" 

63 cmd_split = command.split() 

64 pid = os.fork() 

65 if not pid: 

66 os.execvp(cmd_split[0], cmd_split) 

67 pid, status = os.wait() 

68 # low order bits of status contain the signal that killed the process 

69 # high order bits of status contain the exit code 

70 exitCode = (status & 0xFF00) >> 8 

71 return exitCode