Hi,

This is just a namespace issue, it all runs within the same instance
of Python.  The temporary directory name could be placed into
__builtin__, but that would be ugly and dangerous for a system test to
do this.  So another object which both the script and the code that
executes the script have access to is the relax data store.  So you
could in the setUp() function have something like:

ds.tmpdir = mkdtemp()

or maybe:

ds[ds.current_pipe].tmpdir = mkdtemp()

This will then store the name of the temporary directory, and can be
directly accessible within the script.  It's not the most elegant
solution, but it will work.  You can put anything in the relax data
store, and then it'll be accessible to any other part of relax.  Oh,
and the tearDown() method can use the stored ds.tmpdir to delete that
directory.  Don't forget to reset the relax data store in tearDown to
remove this variable though.

Regards,

Edward


On Thu, Jul 31, 2008 at 6:50 PM, Sébastien Morin
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've tried for a while but can't find how to pass the directory argument
> from the palmer system test to its associated script and then to the
> palmer.create() and palmer.execute() functions.
>
> Does self.relax.interpreter.run() start a new instance of Python ? How
> can one variable be passed through this ?
>
> I am a bit confused... and need help...
>
> Regards,
>
>
> Séb
>
>
>
> Edward d'Auvergne wrote:
>> Hi,
>>
>> For this test, I would avoid changing directories.  The original
>> directory is the directory from which relax was launched, then it
>> changes to the temporary directory, and finally jumps to the relax
>> base directory.  However if you pass directory arguments to the
>> palmer.execute() user function, then this directory switching will be
>> done anyway (although returning to the original directory rather than
>> the relax base directory).  Passing the directory argument (or the
>> directory in front of the file name) to the other palmer user
>> functions will not cause directory changes, but will access files in
>> that directory.  So it shouldn't be necessary to switch directories in
>> the system tests.
>>
>> Regards,
>>
>> Edward
>>
>>
>>
>> On Wed, Jul 30, 2008 at 10:37 PM,  <[EMAIL PROTECTED]> wrote:
>>
>>> Author: semor
>>> Date: Wed Jul 30 22:37:09 2008
>>> New Revision: 7040
>>>
>>> URL: http://svn.gna.org/viewcvs/relax?rev=7040&view=rev
>>> Log:
>>> Changed the temporary directory to the system's default location using 
>>> 'tempfile.mkdtemp'.
>>>
>>> This is in response to a post of Edward d'Auvergne at:
>>> https://mail.gna.org/public/relax-devel/2008-07/msg00048.html (message ID:
>>> [EMAIL PROTECTED]).
>>>
>>>
>>> Modified:
>>>    1.3/test_suite/system_tests/palmer.py
>>>    1.3/test_suite/system_tests/scripts/palmer.py
>>>
>>> Modified: 1.3/test_suite/system_tests/palmer.py
>>> URL: 
>>> http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/palmer.py?rev=7040&r1=7039&r2=7040&view=diff
>>> ==============================================================================
>>> --- 1.3/test_suite/system_tests/palmer.py (original)
>>> +++ 1.3/test_suite/system_tests/palmer.py Wed Jul 30 22:37:09 2008
>>> @@ -22,12 +22,14 @@
>>>
>>>  # Python module imports.
>>>  import sys
>>> +from os import chdir
>>>  from shutil import rmtree
>>> +from tempfile import mkdtemp
>>>  from unittest import TestCase
>>>
>>>  # relax module imports.
>>>  from data import Relax_data_store; ds = Relax_data_store()
>>> -from relax_io import mkdir_nofail, test_binary
>>> +from relax_io import test_binary
>>>
>>>
>>>  class Palmer(TestCase):
>>> @@ -43,7 +45,7 @@
>>>         self.relax.interpreter._Pipe.create('palmer', 'mf')
>>>
>>>         # Create a temporary directory for ModelFree4 outputs.
>>> -        mkdir_nofail(sys.path[-1] + 
>>> '/test_suite/system_tests/data/temp_palmer')
>>> +        self.temp_MF_dir = mkdtemp()
>>>
>>>
>>>     def tearDown(self):
>>> @@ -52,7 +54,7 @@
>>>         ds.__reset__()
>>>
>>>         # Remove the temporary directory created during the execution of 
>>> the test_palmer() function.
>>> -        rmtree(sys.path[-1] + '/test_suite/system_tests/data/temp_palmer/')
>>> +        rmtree(self.temp_MF_dir)
>>>
>>>
>>>     def test_palmer(self):
>>> @@ -64,5 +66,11 @@
>>>         except:
>>>             return
>>>
>>> +        # Move to the temporary directory for ModelFree4 outputs.
>>> +        chdir(self.temp_MF_dir)
>>> +
>>>         # Execute the script.
>>>         self.relax.interpreter.run(script_file=sys.path[-1] + 
>>> '/test_suite/system_tests/scripts/palmer.py')
>>> +
>>> +        # Move back to the base relax directory.
>>> +        chdir(sys.path[-1])
>>>
>>> Modified: 1.3/test_suite/system_tests/scripts/palmer.py
>>> URL: 
>>> http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/scripts/palmer.py?rev=7040&r1=7039&r2=7040&view=diff
>>> ==============================================================================
>>> --- 1.3/test_suite/system_tests/scripts/palmer.py (original)
>>> +++ 1.3/test_suite/system_tests/scripts/palmer.py Wed Jul 30 22:37:09 2008
>>> @@ -1,7 +1,6 @@
>>>  # Script for model-free analysis using the program 'Modelfree4'.
>>>
>>>  # Python module imports.
>>> -from os import chdir
>>>  import sys
>>>
>>>
>>> @@ -121,9 +120,6 @@
>>>  # Set the run name (also the name of a preset model-free model).
>>>  runs = ['m1', 'm2', 'm3']
>>>
>>> -# Move to the temporary directory.
>>> -chdir(sys.path[-1] + '/test_suite/system_tests/data/temp_palmer')
>>> -
>>>  # Run the stages.
>>>  exec_stage_1(runs)
>>>  exec_stage_2(runs)
>>>
>>>
>>> _______________________________________________
>>> relax (http://nmr-relax.com)
>>>
>>> This is the relax-commits mailing list
>>> [EMAIL PROTECTED]
>>>
>>> To unsubscribe from this list, get a password
>>> reminder, or change your subscription options,
>>> visit the list information page at
>>> https://mail.gna.org/listinfo/relax-commits
>>>
>>>
>>
>> _______________________________________________
>> relax (http://nmr-relax.com)
>>
>> This is the relax-devel mailing list
>> [email protected]
>>
>> To unsubscribe from this list, get a password
>> reminder, or change your subscription options,
>> visit the list information page at
>> https://mail.gna.org/listinfo/relax-devel
>>
>>
>
>

_______________________________________________
relax (http://nmr-relax.com)

This is the relax-devel mailing list
[email protected]

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-devel

Reply via email to