API
MigrationResult
dataclass
Result of a content migration operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
migrated
|
int
|
Number of items successfully cloned to the destination portal. |
0
|
skipped
|
int
|
Number of items skipped because they were already present (resume mode). |
0
|
failed
|
int
|
Number of items that could not be cloned due to errors. |
0
|
failures
|
list[dict]
|
List of failure records, each containing |
list()
|
Source code in src/arcgis_cloning/_main.py
migrate_content(source_gis=None, destination_gis=None, source_env='source', destination_env='destination', resume=False, query=None, max_items=None, url_csv_path=None)
Migrate ArcGIS portal content from a source portal to a destination portal.
Connects to both portals, discovers all matching source items, and clones each one
to the destination while mirroring the source folder structure. Per-item clone
failures are recorded in the returned MigrationResult and do not halt the
migration.
Note
Resume mode compares items by (title, type) only. Items with the same title
but a different type are treated as absent and will be cloned. A stable ID-based
mapping is deferred to a future version.
result = migrate_content(resume=True, query="owner:myuser")
print(f"Migrated: {result.migrated}, Skipped: {result.skipped}, Failed: {result.failed}")
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_gis
|
GIS | None
|
Pre-built authenticated |
None
|
destination_gis
|
GIS | None
|
Pre-built authenticated |
None
|
source_env
|
str
|
Key name in |
'source'
|
destination_env
|
str
|
Key name in |
'destination'
|
resume
|
bool
|
When |
False
|
query
|
str | None
|
Item search query string passed to |
None
|
max_items
|
int | None
|
Optional cap on the number of source items to process. |
None
|
url_csv_path
|
Path | str | None
|
Optional path for a CSV file that records the original and updated
URLs of every successfully migrated item. When |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MigrationResult |
MigrationResult
|
Dataclass with |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the source and destination portal URLs are identical, or if
|
KeyError
|
If credentials for |
RuntimeError
|
If the connection to either portal fails. |
Source code in src/arcgis_cloning/_main.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 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 235 236 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 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | |
Module arcgis_cloning.utils
format_df_for_logging(pandas_df, title, line_tab_prefix='\t\t')
Helper function facilitating outputting a Pandas DataFrame into a logfile. This function only formats the data frame into text for output. It should be used in conjunction with a logging method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pandas_df
|
DataFrame
|
Pandas DataFrame to be converted to a string and included in the logfile. |
required |
title
|
str
|
String title describing the data frame. |
required |
line_tab_prefix
|
str
|
Optional string comprised of tabs ( |
'\t\t'
|
Source code in src/arcgis_cloning/utils/_logging.py
get_logger(logger_name=None, level='INFO', logfile_path=None, log_format='%(asctime)s | %(name)s | %(levelname)s | %(message)s', propagate=True, add_stream_handler=False, add_arcpy_handler=False)
Get Python logging.Logger configured to provide stream, file or, if available, ArcPy output.
The way the method is set up, logging will be routed through ArcPy messaging using ArcpyHandler if
ArcPy is available. If ArcPy is not available, messages will be sent to the console using a
logging.StreamHandler. Next, if the logfile_path is provided, log messages will also
be written to the provided path to a logfile using a logging.FileHandler.
Valid log_level inputs include:
* DEBUG - Detailed information, typically of interest only when diagnosing problems.
* INFO - Confirmation that things are working as expected.
* WARNING or WARN - An indication that something unexpected happened, or indicative of some problem in the
near future (e.g. "disk space low"). The software is still working as expected.
* ERROR - Due to a more serious problem, the software has not been able to perform some function.
* CRITICAL - A serious error, indicating that the program itself may be unable to continue running.
Note
Logging levels can be provided as strings (e.g. 'DEBUG'), corresponding integer values or using the
logging module constants (e.g. logging.DEBUG).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logger_name
|
Optional[str]
|
Name of the logger. If |
None
|
level
|
Optional[Union[str, int]]
|
Logging level to use. Default is INFO. |
'INFO'
|
log_format
|
Optional[str]
|
Format string for the logging messages. Default is |
'%(asctime)s | %(name)s | %(levelname)s | %(message)s'
|
propagate
|
bool
|
If |
True
|
logfile_path
|
Optional[Union[Path, str]]
|
Where to save the logfile if file output is desired. |
None
|
add_stream_handler
|
bool
|
If |
False
|
add_arcpy_handler
|
bool
|
If |
False
|
logger = get_logger('DEBUG')
logger.debug('nauseatingly detailed debugging message')
logger.info('something actually useful to know')
logger.warning('The sky may be falling')
logger.error('The sky is falling.')
logger.critical('The sky appears to be falling because a giant meteor is colliding with the earth.')
Source code in src/arcgis_cloning/utils/_logging.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 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 235 236 237 238 | |