- Timestamp:
- 26 May 2009, 20:08:01 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-rewrite/src/waeup/datacenter.txt
r4172 r4174 23 23 24 24 25 Managing the storage path 26 ------------------------- 27 28 We can set another storage path: 29 30 >>> import os 31 >>> os.mkdir('newlocation') 32 >>> newpath = os.path.abspath('newlocation') 33 >>> mydatacenter.setStoragePath(newpath) 34 35 When we set a new storage path, we can tell to move all files in the 36 old location to the new one. To see this feature in action, we first 37 have to put a file into the old location: 38 39 >>> open(os.path.join(newpath, 'myfile.txt'), 'wb').write('hello') 40 41 Now we can set a new location and the file will be copied: 42 43 >>> verynewpath = os.path.abspath('verynewlocation') 44 >>> os.mkdir(verynewpath) 45 46 >>> mydatacenter.setStoragePath(verynewpath, move=True) 47 >>> storagepath = mydatacenter.storage 48 >>> 'myfile.txt' in os.listdir(verynewpath) 49 True 50 51 We remove the created file to have a clean testing environment for 52 upcoming examples: 53 54 >>> os.unlink(os.path.join(storagepath, 'myfile.txt')) 55 25 56 Uploading files 26 57 =============== … … 56 87 Clean up: 57 88 58 >>> os.unlink(filepath) 89 >>> import shutil 90 >>> shutil.rmtree(newpath) 91 >>> shutil.rmtree(verynewpath) 59 92 60 93 … … 166 199 167 200 As we can see, an import is defined here as a tuple of a 168 DataCenterFile and a list of available importers. 201 DataCenterFile and a list of available importers with an associated 202 data receiver (the thing where the data should go to). 169 203 170 204 Clean up:
Note: See TracChangeset for help on using the changeset viewer.