[Tutor] Run a few Python commands from a temporary filesystem when the rootfs is halted

2011-04-22 Thread Frederick Grose
With Bash, when one needs to halt the current root filesystem, to pivot to a
new filesystem, one can copy some of the command files and their
dependencies to a temporary file system and execute from that code base.

Is there a way to accomplish the same within a Python script?

Or must I chain Python and Bash together for this?

  --Fred
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Run a few Python commands from a temporary filesystem when the rootfs is halted

2011-04-22 Thread Steve Willoughby

On 22-Apr-11 16:54, Frederick Grose wrote:

With Bash, when one needs to halt the current root filesystem, to pivot
to a new filesystem, one can copy some of the command files and their
dependencies to a temporary file system and execute from that code base.


I'm not sure those words mean what you think they mean, or I'm missing 
what you're trying to do here.  halting the root filesystem? pivot? code 
base?


You're not trying to talk about jail/chroot, perhaps?

--
Steve Willoughby / st...@alchemy.com
A ship in harbor is safe, but that is not what ships are built for.
PGP Fingerprint 4615 3CCE 0F29 AE6C 8FF4 CA01 73FE 997A 765D 696C
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Run a few Python commands from a temporary filesystem when the rootfs is halted

2011-04-22 Thread Frederick Grose
On Fri, Apr 22, 2011 at 7:59 PM, Steve Willoughby st...@alchemy.com wrote:

 On 22-Apr-11 16:54, Frederick Grose wrote:

 With Bash, when one needs to halt the current root filesystem, to pivot
 to a new filesystem, one can copy some of the command files and their
 dependencies to a temporary file system and execute from that code base.


 I'm not sure those words mean what you think they mean, or I'm missing what
 you're trying to do here.  halting the root filesystem? pivot? code base?

 You're not trying to talk about jail/chroot, perhaps?

 --
 Steve Willoughby / st...@alchemy.com


The particulars are that I've rebuilt a Fedora LiveOS filesystem image from
a currently running instance (incorporating the filesystem changes in the
device-mapper overlay into a new base filesystem image file).

I'd like to halt the active rootfs, switch to its mirror, copy over the
halted filesystem image file with the refreshed version, and then switch
back.

--Fred
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Run a few Python commands from a temporary filesystem when the rootfs is halted

2011-04-22 Thread Steven D'Aprano

Frederick Grose wrote:

With Bash, when one needs to halt the current root filesystem, to pivot to a
new filesystem, one can copy some of the command files and their
dependencies to a temporary file system and execute from that code base.

Is there a way to accomplish the same within a Python script?


This is way off-topic for a Python tutor list. This is about learning 
the Python programming language, not the intricate corners of (I assume) 
Linux system administration.


I would imagine that it would be very, very difficult in Python, because 
you would need somehow to end the *current* Python process and start up 
a *new* Python process running from executables on the new file system, 
without manual intervention.


I strongly suggest you take this question to the main Python list, 
pyt...@python.org, which is also available as a news group 
comp.lang.python, and show the bash code you are trying to duplicate. 
There's no guarantee you'll get an answer there either, but it's more 
likely than here.


Good luck!


--
Steven

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Run a few Python commands from a temporary filesystem when the rootfs is halted

2011-04-22 Thread Steve Willoughby

On 22-Apr-11 17:14, Frederick Grose wrote:

The particulars are that I've rebuilt a Fedora LiveOS filesystem image
from a currently running instance (incorporating the filesystem changes
in the device-mapper overlay into a new base filesystem image file).


Right, so essentially you're talking about chrooting into the LiveOS 
image temporarily.  It's not really halting as such, just where the 
OS's idea of root is at the moment.  That involves mounting your 
LiveOS filesystem as well.


The short answer is that if you can do it in the shell, you can do it in 
Python, but there's got to be more to the story than just this.  What 
are you trying to actually do that you need Python for this?  I assume 
you're trying to automate the process of what you're doing?


Almost probably this is possible with Python, if I understand what 
you're doing.  If you just want to know how to write a Python script 
around the steps you want to accomplish, as a simple beginning Python 
experience, we may still be of service to you.


We could, for example point you to read up on the os.chroot() function 
in the Python standard library.


If your question has more to do with the particulars of managing 
chroot()ed mountpoints or preparing LiveOS images, you'd need to look to 
a forum devoted to that.



--
Steve Willoughby / st...@alchemy.com
A ship in harbor is safe, but that is not what ships are built for.
PGP Fingerprint 4615 3CCE 0F29 AE6C 8FF4 CA01 73FE 997A 765D 696C
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Run a few Python commands from a temporary filesystem when the rootfs is halted

2011-04-22 Thread Frederick Grose
On Fri, Apr 22, 2011 at 8:55 PM, Steve Willoughby st...@alchemy.com wrote:

 On 22-Apr-11 17:14, Frederick Grose wrote:

 The particulars are that I've rebuilt a Fedora LiveOS filesystem image
 from a currently running instance (incorporating the filesystem changes
 in the device-mapper overlay into a new base filesystem image file).


 Right, so essentially you're talking about chrooting into the LiveOS image
 temporarily.  It's not really halting as such, just where the OS's idea of
 root is at the moment.  That involves mounting your LiveOS filesystem as
 well.

 The short answer is that if you can do it in the shell, you can do it in
 Python, but there's got to be more to the story than just this.  What are
 you trying to actually do that you need Python for this?  I assume you're
 trying to automate the process of what you're doing?

 Almost probably this is possible with Python, if I understand what you're
 doing.  If you just want to know how to write a Python script around the
 steps you want to accomplish, as a simple beginning Python experience, we
 may still be of service to you.

 We could, for example point you to read up on the os.chroot() function in
 the Python standard library.

 If your question has more to do with the particulars of managing chroot()ed
 mountpoints or preparing LiveOS images, you'd need to look to a forum
 devoted to that.


 --
 Steve Willoughby / st...@alchemy.com


Thank you Steve and Steven for your assistance!

I misread this sentence in the list description, While the list is called
tutor, anyone, whether novice or expert, can answer questions. .. to
include 'ask' as well as answer questions that may be instructive.

I've posted in Python-list, as suggested.

Steven's synopsis, ... you would need somehow to end the *current* Python
process and start up a *new* Python process running from executables on the
new file system, without manual intervention. is the situation I'm
attempting.

I have written the LiveOS rebuilding code in Python, and am working to
complete the operation in Python, if possible, but don't know enough about
how the Python shutdown and startup might be scripted within Python.

--Fred
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Run a few Python commands from a temporary filesystem when the rootfs is halted

2011-04-22 Thread Steven D'Aprano

Frederick Grose wrote:


I misread this sentence in the list description, While the list is called
tutor, anyone, whether novice or expert, can answer questions. .. to
include 'ask' as well as answer questions that may be instructive.



Well, you can *ask*, but the number of people on this list is much 
smaller than the main python list, and we tend to be focused more on 
beginner questions and learning the language rather than the more 
advanced stuff. So it's more about maximising your chances of getting a 
good answer.




--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor