summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2022-03-19 10:26:09 +0100
committerMaxime “pep” Buquet <pep@bouah.net>2022-03-20 01:02:14 +0100
commit53d38a81154a0cf5adbe798af6a9af739079e65b (patch)
treecd264d33ca93e7148294f531cc24fdd191462aed /examples
parent0fba8fd7f842ceb0fd52c0e940d75e4b948e2b56 (diff)
downloadslixmpp-53d38a81154a0cf5adbe798af6a9af739079e65b.tar.gz
slixmpp-53d38a81154a0cf5adbe798af6a9af739079e65b.tar.bz2
slixmpp-53d38a81154a0cf5adbe798af6a9af739079e65b.tar.xz
slixmpp-53d38a81154a0cf5adbe798af6a9af739079e65b.zip
setup.py: add cryptography in extras_require; update example
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/http_upload.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/examples/http_upload.py b/examples/http_upload.py
index 7f1c44bc..b62c736e 100755
--- a/examples/http_upload.py
+++ b/examples/http_upload.py
@@ -48,7 +48,15 @@ class HttpUpload(slixmpp.ClientXMPP):
log.info('Uploading file %s...', self.filename)
try:
upload_file = self['xep_0363'].upload_file
- if self.encrypted:
+ if self.encrypted and not self['xep_0454']:
+ print(
+ 'The xep_0454 module isn\'t available. '
+ 'Ensure you have \'cryptography\' '
+ 'from extras_require installed.',
+ file=sys.stderr,
+ )
+ return
+ elif self.encrypted:
upload_file = self['xep_0454'].upload_file
url = await upload_file(
self.filename, domain=self.domain, timeout=10,
@@ -135,7 +143,13 @@ if __name__ == '__main__':
xmpp.register_plugin('xep_0071')
xmpp.register_plugin('xep_0128')
xmpp.register_plugin('xep_0363')
- xmpp.register_plugin('xep_0454')
+ try:
+ xmpp.register_plugin('xep_0454')
+ except slixmpp.plugins.base.PluginNotFound:
+ log.error(
+ 'Could not load xep_0454. '
+ 'Ensure you have \'cryptography\' from extras_require installed.'
+ )
# Connect to the XMPP server and start processing XMPP stanzas.
xmpp.connect()