123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- def archive_room(self, room_id: str, text_format: bool = True, html_format: bool = True,
- json_format: bool = True, **options) -> str:
- """
- Archives a Webex Teams room. This creates a file called roomTitle_timestamp_roomId with the
- appropriate file extension as defined by file_format param with the following contents:
- - roomTitle_roomId.txt - Text version of the conversations (if `text_format` is True)
- - roomTitle_roomId.html - HTML version of the conversations (if `html_format` is True)
- - files/ - Attachments added to the room (if `download_attachments` is True)
- Args:
- room_id: ID of the room to archive.
- text_format: Create a text version of the archive.
- html_format: Create an HTML version of the archive.
- json_format: Create a json version of the archive.
- Options:
- compress_folder: Compress archive folder.
- delete_folder: Delete the archive folder when done.
- reverse_order: Order messages by most recent on the bottom.
- download_attachments: Download attachments sent to the room.
- download_avatars: Download avatar images.
- download_workers: Number of download workers for downloading files.
- timestamp_format: Timestamp strftime format.
- file_format: Archive format as supported by shutil.make_archive
-
- Returns:
- Name of archive file.
- Raises:
- IOError: Error occurred while creating/writing to files.
- shutil.Error: Error occurred creating/copying/deleting files/folders.
- ValueError: Exception message will contain more details.
- TypeError: Messages contained non JSON serializable data.
- webexteamssdkException: An error occurred calling the Webex Teams API.
- """
- # Configure options
- compress_folder = options.get("compress_folder", True)
- delete_folder = options.get("delete_folder", False)
- reverse_order = options.get("reverse_order", True)
- download_attachments = options.get("download_attachments", True)
- download_avatars = options.get("download_avatars", True)
- download_workers = options.get("download_workers", 15)
- timestamp_format = options.get("timestamp_format", "%Y-%m-%dT%H:%M:%S")
- file_format = options.get("file_format", "gztar")
- if delete_folder and not compress_folder:
- raise ValueError("delete_folder cannot be True while compress_folder is False")
- self._gather_room_information(room_id, download_avatars)
- # Prepare folder
- self._setup_folder(download_attachments, download_avatars, html_format)
- try:
- self._archive(reverse_order, download_attachments, download_avatars, download_workers,
- text_format, html_format, json_format, timestamp_format)
-
- if compress_folder:
- filename = self._compress_folder(file_format)
- else:
- filename = self.archive_folder_name
- except Exception:
- self._tear_down_folder()
- raise
- if delete_folder:
- self._tear_down_folder()
- return filename
|