[Tutor] Remote module loading
devN
eishf2000 at gmail.com
Thu Sep 7 02:49:08 EDT 2017
Hi,
I am newbie in python. I wrote a module which is meant to be run across
couple of unix OS variants (redhat, debian, bsd and solaris). The module is
updated frequently and new features added.
import platform
import os
import subprocess
def main ():
RESPONSE = dict ();
PYVER = float (platform.python_version_tuple ()[0] + "." +
platform.python_version_tuple ()[1]);
if PYVER < 2.4:
return;
RESPONSE["HOSTNAME"] = platform.node ();
RESPONSE["MEMORY"] = str (float (os.sysconf ('SC_PAGE_SIZE')) *
os.sysconf ('SC_PHYS_PAGES') /(1024 * 1024 * 1024)) +"GB";
RESPONSE["OSTYPE"] = platform.system ();
RESPONSE["OSKERNEL"] = platform.uname ()[3];
RESPONSE["PROCESSOR"] = platform.processor ();
if 'SunOS' in RESPONSE.values ():
RESPONSE["CORECOUNT"] = re.sub ('\s+', '',subprocess.Popen
("/usr/sbin/psrinfo | wc -l | cat", shell =True, stdout = subprocess.PIPE,
stderr =subprocess.STDOUT).stdout.readline ());
RESPONSE["OSVERSION"] = platform.release ();
if 'Linux' in RESPONSE.values ():
RESPONSE["OSKERNEL"] = platform.release ();
RESPONSE["OSVERSION"] = platform.linux_distribution ()[0] + " " +
platform.linux_distribution ()[1];
RESPONSE["CORECOUNT"] = CPUCOUNT;
print (RESPONSE);
if __name__== '__main__':
main ()
The above code was an alpha and there could be further optimizations which
I request you to overlook.
My requirement is, I have an agent copied in all the UNIX variants and I
have done that only once and dont want to do it again (too many machines
and no possibility of ansible or chef implementation). The agent currently
loads the module locally but I need to let all clients know that the module
is updated with new features, but really can't.
So I thought to expose the module as plain text over http from a remote
apache container. Is there any way to load the module from remote just as
simple as import statement (without using urllib or wget piped to python)?
This could also mean does PYTHONPATH support http/ftp?
Thanks
More information about the Tutor
mailing list