Changeset 21 for branches

Show
Ignore:
Timestamp:
05/26/06 15:54:32 (7 years ago)
Author:
mk
Message:

Use tempfile.gettempdir() instead of fixed /tmp/.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/mk/cheesecake/cheesecake_index.py

    r18 r21  
    3232from codeparser import CodeParser 
    3333 
     34default_temp_directory = os.path.join(tempfile.gettempdir(), 'cheesecake_sandbox') 
     35 
     36 
    3437class Index(object): 
    3538    """ 
     
    131134        if not self.name and not self.url and not self.package_path: 
    132135            self.raise_exception("No package name, URL or path specified ... exiting") 
    133         self.sandbox = sandbox or "/tmp/cheesecake_sandbox" 
     136        self.sandbox = sandbox or default_temp_directory 
    134137        if not os.path.isdir(self.sandbox): 
    135138            os.mkdir(self.sandbox) 
     
    974977                      default="", help="package path on local file system") 
    975978    parser.add_option("-s", "--sandbox", dest="sandbox", 
    976                       default="/tmp/cheesecake_sandbox",  
    977                       help="directory where package will be unpacked (default=/tmp/cheesecake_sandbox)"
     979                      default=default_temp_directory, 
     980                      help="directory where package will be unpacked (default=%s)" % default_temp_directory
    978981    parser.add_option("-c", "--config", dest="config", 
    979982                      default=None, 
  • branches/mk/tests/test_index_unpack.py

    r8 r21  
    11import _path_cheesecake 
    22from cheesecake.cheesecake_index import Cheesecake, CheesecakeError, pad_msg 
     3 
    34import os 
     5import tempfile 
     6 
     7default_temp_directory = os.path.join(tempfile.gettempdir(), 'cheesecake_sandbox') 
    48datadir = os.path.abspath(os.path.join(os.path.dirname(__file__), "data")) 
    59 
    6 class TestIndexUnpack
     10class TestIndexUnpack(object)
    711 
    812    def setUp(self): 
     
    4145            assert 0 # This statement should not be reached 
    4246        except CheesecakeError, e: 
    43             msg = "Could not read tar file /tmp/cheesecake_sandbox/invalid_package.tar.gz ... exiting\n" 
     47            msg = "Could not read tar file %s ... exiting\n" % \ 
     48                  os.path.join(default_temp_directory, 'invalid_package.tar.gz') 
    4449            msg += pad_msg("CHEESECAKE INDEX", 0) 
    4550            assert str(e) == msg 
     
    5055            assert 0 # This statement should not be reached 
    5156        except CheesecakeError, e: 
    52             msg = "Could not read tar file /tmp/cheesecake_sandbox/invalid_package.tgz ... exiting\n" 
     57            msg = "Could not read tar file %s ... exiting\n" % \ 
     58                  os.path.join(default_temp_directory, 'invalid_package.tgz') 
    5359            msg += pad_msg("CHEESECAKE INDEX", 0) 
    5460            assert str(e) == msg 
     
    5965            assert 0 # This statement should not be reached 
    6066        except CheesecakeError, e: 
    61             msg = "Error unzipping file /tmp/cheesecake_sandbox/invalid_package.zip ... exiting\n" 
     67            msg = "Error unzipping file %s ... exiting\n" % \ 
     68                  os.path.join(default_temp_directory, 'invalid_package.zip') 
    6269            msg += pad_msg("CHEESECAKE INDEX", 0) 
    6370            assert str(e) == msg 
  • branches/mk/tests/test_index_url_download.py

    r20 r21  
    33         
    44import os 
     5import tempfile 
     6 
     7default_temp_directory = os.path.join(tempfile.gettempdir(), 'cheesecake_sandbox') 
    58 
    69 
     
    5053                assert 0 # This statement should not be reached 
    5154            except CheesecakeError, e: 
    52                 msg = "Could not read tar file /tmp/cheesecake_sandbox/not_there.tar.gz ... exiting\n" 
     55                msg = "Could not read tar file %s ... exiting\n" % \ 
     56                      os.path.join(default_temp_directory, 'not_there.tar.gz') 
    5357                msg += pad_msg("CHEESECAKE INDEX", 0) 
    5458                assert str(e) == msg