#!/usr/bin/env python ################################################################################ #\defgroup difxmkdir DiFXmkdir # #\brief Run a simple "mkdir" file operation on the DiFX server. # # Usage: DiFXmkdir [options] PATH # # DiFXMkdir can be used to make a new directory on the DiFX server. # If given a complex path serveral levels of which don't exist it will create # all necessary directories. The directory is built on the server using a # standard mkdir command which cannot be modified with any arguments. # # The user running the DiFX server must have permission to perform the mkdir # operation. # #

Command Line Arguments

# # #
-D, --difx VERSION
Run using a specific DiFX version. If not specified # the value of the DIFX_VERSION environment variable will # be used. Failing that, "DIFX-DEVEL" will be used. #
-h, --help
Print help information and quit. #
-H, --hostname NAME
Use NAME as the host of the difxServer program. # Default is to use DIFX_CONTROL_HOST environment variable. #
-P, --port PORT
Use PORT as the TCP port to communicated with the difxServer. # Default is to use DIFX_CONTROL_PORT environment variable. #
# ################################################################################ program = 'DiFXmkdir' version = '0.1' author = 'John Spitzak' verdate = '20150721' import sys import time import DiFXControl #=============================================================================== # MAIN #=============================================================================== host = None port = None pathStr = None usageError = False # Locate a "default" DiFX Version from environment variables. User may change this # with command line arguments. try: DiFXVersion = os.environ["DIFX_VERSION"] except: DiFXVersion = "DIFX-DEVEL" try: i = 1 otherArgs = [] argStr = None pathStr = None while i < len( sys.argv ): # Check against legal argument types. Anything we don't recognize is assumed # to be part of a list of message types. if sys.argv[i] in [ "-h", "--help" ]: print '\n%s ver %s %s %s' % (program, version, author, verdate) print "Creates a specified path on the DiFX software correlator." print "Usage: %s [options] PATH" % ( sys.argv[0] ) print "" print "Options can include:" print "" print " --difx VERSION" print " -D VERSION Run using a specific DiFX version. If not specified" print " the value of the DIFX_VERSION environment variable will" print " be used. Failing that, \"DIFX-DEVEL\" will be used." print "" print " --help" print " -h Print this help information and quit." print "" print " --hostname NAME" print " -H NAME Use NAME as the host of the difxServer program." print " Default is to use DIFX_CONTROL_HOST environment variable." print "" print " --port PORT" print " -P PORT Use PORT as the TCP port to communicated with the difxServer." print " Default is to use DIFX_CONTROL_PORT environment variable." print "" exit( 0 ) elif sys.argv[i] in [ "-H", "--hostname" ]: host = sys.argv[i+1] i = i + 1 elif sys.argv[i] in [ "-D", "--difx" ]: DiFXVersion = sys.argv[i+1] i = i + 1 elif sys.argv[i] in [ "-P", "--port" ]: port = int( sys.argv[i+1] ) i = i + 1 else: otherArgs.append( sys.argv[i] ) i = i + 1 # Last argument is the path name of the directory we are making. The server # doesn't accept any arguments for mkdir, which is annoying. for arg in otherArgs: pathStr = arg except RuntimeError: usageError = True if pathStr == None: usageError = True if usageError: print "Usage: %s [options] " % ( sys.argv[0] ) exit( 0 ) # Open a new connection to the difxServer... difx = DiFXControl.Client() difx.connect( host = host, port = port ) if difx.socketOK: difx.monitor() difx.version( DiFXVersion ) difx.mkdir( pathStr ) difx.close()