[Tutor] accessing another system's environment

Modulok modulok at gmail.com
Sat Feb 26 13:16:17 CET 2011


I'm coming into this thread late so I might be off the mark here, but
it seems like you're going about it backwards:

Instead of trying to reach in and modify a user's environment, which
is highly variable and process dependent, why not just wrap the
software they're running? Have a python script wrap all of the
programs you're trying to configure on the client's machine. (No
matter how you do it, you'd have to install a client program of some
kind anyway.) When they launch the 'program' in question, they're
really launching a python script. The script checks in with a remote
server that holds the config files or environment data. (Or whatever
else you need.) The client script says some thing like "I'm john,
running program version x.x. Give me my env variables".)

The server then replies with any variables that the client needs to
set and their values. You could do this with a python script running
on a server sending ajax responses. (There's an ajax module in the
standard library.) The wrapper, running on the client gets the
response and set any environment variables for the process it's about
to launch. It then starts the real program, passing the properly
configured environment on to it.

You have to write two programs. 1. A client wrapper that asks the
server for its data and 2. A simple server that passes any data back
to the client.

In effect, you'll be able to change the clients configuration,
environment variables or *anything else* that needs done before your
script launches the the real client program. You don't have to deal
with screwing around with the client's environment or the complexities
that brings up either.


On 2/26/11, Dave Angel <davea at ieee.org> wrote:
> On 01/-10/-28163 02:59 PM, Steve Willoughby wrote:
>> On 26-Feb-11 01:19, ALAN GAULD wrote:
>>> Bill,
>>>
>>> That's the same thing we are talking about.
>>> The problem is those environment variables are
>>> highly variable so you can't talk about a machine's environment.
>>> Two users on the same machine (at the same time) may have
>>> very different environments. And a batch file or program can
>>
>> I'm a Unix hacker, so forgive me if my understanding of Windows is a bit
>> naive. I think, though, that Windows has a set of environment variables
>> which are system-wide, added automatically to the user set of variables
>> when a new process is launched. Yes, they can be changed or deleted but
>> there is a standard set applied to all users.
>>
>> If that's a correct assumption on my part, there must be somewhere that
>> can be read from, probably (I would guess) in the registry. So a script
>> which could read/write those registry keys may do what is required here.
>>
>> The issue of exposing that to remote machines remains a dangling issue,
>> though.
>>
>> Of course, it's not entirely clear we're solving a Python question,
>> although this discussion may well go more solidly into that space.
>>
>
> Indeed.  in Windows, there are two sets of registry keys for environment
> variables, one is system wide, and one is per user.  When Explorer
> launches a console or an application for a particular user, it combines
> those two sets of keys to come up with an initial set of environment
> variables.
>
> I tried to launch a VirtualBox XP machine, but it failed for some
> reason.  Probably I have too much else running.  So I can't tell you the
> key names.
>
> I'd suggest asking about remotely accessing the registry on the
> python-win32 forum.  I'm sure the win32 extension have a way, I just
> don't know if it'll work from a Linux client.
>
> DaveA
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list