utils
compute_fileset_matches
Link
compute_fileset_matches(scan)
Return a dictionary mapping the scan tasks to fileset names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Scan
|
The scan instance to list the filesets from. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary mapping the scan tasks to fileset names. |
Examples:
>>> from plantdb.server.core.utils import compute_fileset_matches
>>> from plantdb.commons.test_database import dummy_db
>>> db = dummy_db(with_fileset=True)
>>> scan = db.get_scan("myscan_001")
>>> compute_fileset_matches(scan)
{'fileset': 'fileset_001'}
>>> db.disconnect() # clean up (delete) the temporary dummy database
Source code in plantdb/server/core/utils.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
get_file_uri
Link
Return the URI for the corresponding scan/fileset/file tree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Scan or str
|
A |
required |
|
Fileset or str
|
A |
required |
|
File or str
|
A |
required |
Returns:
| Type | Description |
|---|---|
str
|
The URI for the corresponding |
Examples:
>>> from plantdb.server.core.utils import compute_fileset_matches
>>> from plantdb.server.core.utils import get_file_uri
>>> from plantdb.commons.test_database import test_database
>>> db = test_database('real_plant_analyzed')
>>> db.connect()
>>> scan = db.get_scan('real_plant_analyzed')
>>> fs_match = compute_fileset_matches(scan)
>>> fs = scan.get_fileset(fs_match['PointCloud'])
>>> f = fs.get_file("PointCloud")
>>> get_file_uri(scan, fs, f)
'/files/real_plant_analyzed/PointCloud_1_0_1_0_10_0_7ee836e5a9/PointCloud.ply'
Source code in plantdb/server/core/utils.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
get_image_uri
Link
Return the URI for the corresponding scan/fileset/file tree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Scan or str
|
A |
required |
|
Fileset or str
|
A |
required |
|
File or str
|
A |
required |
|
(orig, large, thumb)
|
If an integer, use it as the size of the cached image to create and return.
Otherwise, should be one of the following strings, default to
|
'orig'
|
|
bool
|
A boolean flag indicating whether to return an image as a base64 string. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The URI for the corresponding |
Examples:
>>> from plantdb.server.core.utils import get_image_uri
>>> from plantdb.commons.test_database import test_database
>>> from plantdb.server.core.utils import compute_fileset_matches
>>> db = test_database('real_plant_analyzed')
>>> db.connect()
>>> scan = db.get_scan('real_plant_analyzed')
>>> get_image_uri(scan, 'images', '00000_rgb.jpg', size='orig')
'/image/real_plant_analyzed/images/00000_rgb.jpg?size=orig'
>>> get_image_uri(scan, 'images', '00011_rgb.jpg', size='thumb', as_base64=True)
'/image/real_plant_analyzed/images/00011_rgb.jpg?size=thumb&as_base64=true'
Source code in plantdb/server/core/utils.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
get_scan_date
Link
get_scan_date(scan)
Get the acquisition datetime of a scan.
Try to get the data from the scan metadata 'acquisition_date', else from the directory creation time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Scan
|
The scan instance to get the date & time from. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The formatted datetime string. |
Examples:
>>> from plantdb.server.core.utils import get_scan_date
>>> from plantdb.commons.test_database import test_database
>>> db = test_database(['real_plant_analyzed', 'virtual_plant_analyzed'])
>>> db.connect()
>>> scan = db.get_scan('real_plant_analyzed')
>>> print(get_scan_date(scan))
>>> scan = db.get_scan('virtual_plant_analyzed')
>>> print(get_scan_date(scan))
>>> db.disconnect()
Source code in plantdb/server/core/utils.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
get_scan_template
Link
get_scan_template(scan_id, error=False)
Template dictionary for a scan.
Source code in plantdb/server/core/utils.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |