Skip to content

Instantly share code, notes, and snippets.

@PVince81
Created August 23, 2021 13:38
Show Gist options
  • Save PVince81/9f82014724bdf9e420f57444ee33ce82 to your computer and use it in GitHub Desktop.
Save PVince81/9f82014724bdf9e420f57444ee33ce82 to your computer and use it in GitHub Desktop.
Create received shares
#!/usr/bin/env python3
# Instructions:
#
# Make sure to run: pip3 install pyocclient
# Might require PYTHONPATH when running if pyocclient is not installed in standard location.
#
import time
import sys
import owncloud
ADMIN_USER=('admin', 'admin')
TEST_USER_SENDER=('test-sender', 'test12345678')
TEST_USER_RECIPIENT=('test-recipient', 'test12345678')
FOLDER_COUNT = 5
if len(sys.argv) >= 2:
FOLDER_COUNT = int(sys.argv[1])
timestamp = time.time()
c = owncloud.Client('https://vvortex.local')
c.login(ADMIN_USER[0], ADMIN_USER[1])
if not c.user_exists(TEST_USER_SENDER[0]):
c.create_user(TEST_USER_SENDER[0], TEST_USER_SENDER[1])
if not c.user_exists(TEST_USER_RECIPIENT[0]):
c.create_user(TEST_USER_RECIPIENT[0], TEST_USER_RECIPIENT[1])
c.login(TEST_USER_SENDER[0], TEST_USER_SENDER[1])
PATTERN = '%d_test_share_%i'
for i in range(FOLDER_COUNT):
path = PATTERN % (timestamp, i)
print('Creating and sharing ' + path)
c.mkdir(path)
c.share_file_with_user(path, TEST_USER_RECIPIENT[0])
c.login(TEST_USER_RECIPIENT[0], TEST_USER_RECIPIENT[1])
if not c.file_info(PATTERN % (timestamp, 1)):
sys.stderr.write('Failed')
sys.exit(1)
print('Done')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment