File tree Expand file tree Collapse file tree 1 file changed +10
-13
lines changed Expand file tree Collapse file tree 1 file changed +10
-13
lines changed Original file line number Diff line number Diff line change 33Display Slurm node information in XML
44"""
55
6+ import argparse
67import os
78import os .path
89import pwd
910import re
1011import socket
1112import sys
1213import time
13- from optparse import OptionParser
1414
1515import pyslurm
1616
@@ -89,37 +89,34 @@ def meminfo():
8989
9090if __name__ == "__main__" :
9191
92- USAGE = "Usage: %prog [options] arg"
93- parser = OptionParser (USAGE )
94-
95- parser .add_option (
92+ parser = argparse .ArgumentParser (description = "Slurm Node XML Output" )
93+ parser .add_argument (
9694 "-o" ,
9795 "--stdout" ,
9896 dest = "output" ,
9997 action = "store_true" ,
10098 default = False ,
10199 help = "Write to standard output" ,
102100 )
103- parser .add_option (
101+ parser .add_argument (
104102 "-d" ,
105103 "--dir" ,
106104 dest = "directory" ,
107105 action = "store" ,
108- default = os .getcwd () ,
106+ default = os .getcwd ,
109107 help = "Directory to write data to" ,
110108 )
111- parser .add_option (
109+ parser .add_argument (
112110 "-r" ,
113111 "--rrd" ,
114112 dest = "rrd" ,
115- default = False ,
116113 action = "store_true" ,
114+ default = False ,
117115 help = "Write rrd data" ,
118116 )
117+ options = parser .parse_args ()
119118
120- (options , args ) = parser .parse_args ()
121-
122- hosts = socket .gethostbyaddr (socket .gethostname ())[1 ]
119+ hosts = socket .gethostbyaddr (socket .gethostname ())
123120 my_host = hosts [0 ]
124121
125122 LOCK_FILE = "/var/tmp/slurm_node_xml.lck"
@@ -162,7 +159,7 @@ def meminfo():
162159 sys .stdout .write ("\t <slurmd>\n " )
163160 for key , value in data .items ():
164161 sys .stdout .write (f"\t \t <{ key } >{ value } </{ key } >\n " )
165- sys .stdout .write ("\t </slurmd>\n " )
162+ sys .stdout .write ("\t </slurmd>\n " )
166163
167164 a = pyslurm .job ()
168165 jobs = a .get ()
You can’t perform that action at this time.
0 commit comments