Re: [Tutor] Remote module loading

2017-09-07 Thread devN
In fact, that's very close to what I needed. The repo or source would have
version, target audience, and few other parameters. Thanks a zillion. I
will take it up from here. I'll post you guys the complete version sometime
in the future when it's ready.
Cheers!
Farhan

On Fri, 8 Sep 2017, 06:26 Mats Wichmann  wrote:

> On 09/07/2017 12:49 AM, devN wrote:
> > 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.
> >
> ...
> > 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
>
> We had a bit of a discussion not too long ago about the general topic.
> You can search in the list archive for "How to deploy seamless script
> updates to your clients"
>
> You've left a situation that isn't really very flexible since you say
> you don't want to copy the agent again.  Nonetheless, I'll point you to
> a little bit of fiddling I did on this topic that you could just chew on
> and see if it makes any sense.  It's not really "newbie" code.  The
> basic idea is that you have a known location which contains a file with
> information about available releases; the module has a function a
> participating script can call to find out if it has a new version
> available.
>
> Link to my pointer to this:
> https://www.mail-archive.com/tutor@python.org/msg76681.html
>
>
> The rest of the discussion has some other good ideas in it too (a
> version control server may be able to provide a kind of solution).
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Remote module loading

2017-09-07 Thread devN
Well, it's another hassle to keep NFS shared and mounted in every other
systems, not to include the firewall rules.
Let me check out with the importlib

On Fri, 8 Sep 2017, 00:14 Peter Otten <__pete...@web.de> wrote:

> devN wrote:
> > 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?
>
> While there are hooks to do everything you can imagine
>
> https://docs.python.org/dev/library/importlib.html
>
> that's not very accessible to newbies.
>
> Why don't you make the module available through the file system? Think NFS
> or SMB or WebDAV...
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Remote module loading

2017-09-07 Thread devN
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
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor