/usr/lib/python2.7/dist-packages/framework/subsystems/onetworkd/helpers.py is in fso-frameworkd 0.10.1-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | from string import maketrans
import logging
logger = logging.getLogger('onetworkd')
#============================================================================#
def isValidAddress( address ):
#============================================================================#
parts = address.split( '.' )
if len( parts ) != 4:
return False
try:
for part in parts:
if 0 > int( part ) or 255 < int ( part ):
return False
return True
except ValueError:
return False
#============================================================================#
def readFromFile( path ):
#============================================================================#
try:
value = open( path, 'r' ).read().strip()
except IOError, e:
logger.warning( "(could not read from '%s': %s)" % ( path, e ) )
return "N/A"
else:
logger.debug( "(read '%s' from '%s')" % ( value, path ) )
return value
#============================================================================#
def writeToFile( path, value ):
#============================================================================#
logger.debug( "(writing '%s' to '%s')" % ( value, path ) )
try:
f = open( path, 'w' )
except IOError, e:
logger.warning( "(could not write to '%s': %s)" % ( path, e ) )
else:
f.write( "%s\n" % value )
#============================================================================#
def cleanObjectName( name ):
#============================================================================#
return name.translate( trans )
trans = maketrans( "-:", "__" )
|