RE: simply python modules question

Date : Thu, 21 Jul 2005 17:49:59 -0400
To : XSI(at)Softimage.COM
From : xsibrad(at)fie.us
Subject : RE: simply python modules question
After much frustration, I went with the following solution that seems to be
working. (hopefully my mail client wont slaughter the tabs.)

[code]
import sys
Application.LogMessage("Attempting to Reload all PLF modules.")
dict = sys.modules.keys()
for m in dict:
	if m.startswith("PLF"):

		if sys.modules[m] != None:
			Application.LogMessage("Reloading:" + m)
			reload(sys.modules[m])
		else:
			Application.LogMessage("Module entry " + m + " was Null")
Application.LogMessage("Finished Reloading all PLF modules.")
[/code]

So we can at will flush the modules of our PLF package and force a reload of the
whole thing for development purposes.

This solution does not require explicite "reload" function calls within other
commands or modules.  So I kinda like this.

Thanks to all for their input.

-brad

Quoting xsibrad(at)fie.us:

> No, I kept it a good old normal command.  So changes to the actual command
> .py
> file do update immediately... unlike with a self installed plugin in which I
> would have to reload it.  Its the modules referenced from the command .py
> file
> with an import statement that are not updating.
>
> -brad
>
> Quoting kim aldis <kim(at)aldis.org.uk>:
>
> > How is the command built, through a self-installing plugin?
> >
> > > -----Original Message-----
> > > From: owner-xsi(at)Softimage.COM
> > > [mailto:owner-xsi(at)Softimage.COM] On Behalf Of xsibrad(at)fie.us
> > > Sent: 20 July 2005 22:24
> > > To: xsi(at)Softimage.COM
> > > Subject: simply python modules question
> > >
> > > Hi,
> > >
> > > I've got a command that's importing a custom python module.
> > >
> > > I've added the package to the PYTHONPATH variable and it runs.
> > >
> > > However, if I open the module, make a change, and save it, I
> > > have to restart XSI in order for the change to make it into
> > > the XSI execution environment.
> > >
> > > Is there a well known and accepted way to have the XSI python
> > > execution evironment flush the module from memory and reload
> > > it from the new source without having to restart XSI?
> > >
> > > Before I spend hours trying to work around this myself, I
> > > thought I'd check with the minds on the list.  I'm fairly new
> > > to Python.
> > >
> > > Thanks.
> > >
> > > -brad
> > >
> > >
> > >
> > > ----------------------------------------------------------------
> > > This message was sent using IMP, the Internet Messaging Program.
> > >
> > > ---
> > > Unsubscribe? Mail Majordomo(at)Softimage.COM with the following
> > > text in body:
> > > unsubscribe xsi
> > >
> > >
> >
> > ---
> > Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
> > unsubscribe xsi
> >
>
>
>
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
> ---
> Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
> unsubscribe xsi
>




----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.