Skip to content

Commit

Permalink
test(gui): download syncstate.py if not available
Browse files Browse the repository at this point in the history
  • Loading branch information
saw-jan committed Sep 5, 2023
1 parent e69743d commit 9ab451a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
2 changes: 2 additions & 0 deletions test/gui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
shared/scripts/custom_lib
reports
1 change: 1 addition & 0 deletions test/gui/shared/scripts/helpers/ConfigHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
'clientConfigDir': '/tmp/owncloud-client/',
'guiTestReportDir': os.path.abspath('../reports/'),
'ocis': False,
'custom_lib': os.path.abspath('../shared/scripts/custom_lib'),
}

READONLY_CONFIG = list(CONFIG_ENV_MAP.keys())
Expand Down
36 changes: 30 additions & 6 deletions test/gui/shared/scripts/helpers/SyncHelper.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,41 @@
import re
import sys
import test
from os.path import realpath
import os
import urllib
from squish import waitFor, snooze

from helpers.FilesHelper import sanitizePath
from helpers.ConfigHelper import get_config

# NOTE: 'syncstate.py' was removed from client
# and is now available at 'owncloud/client-desktop-shell-integration-nautilus'
# check if 'syncstate.py' is available, if not, download it
custom_lib = get_config('custom_lib')
syncstate_lib_file = os.path.join(custom_lib, 'syncstate.py')
if not os.path.exists(custom_lib):
os.makedirs(get_config('custom_lib'), exist_ok=True)
if not os.path.exists(syncstate_lib_file):
URL = "https://raw.github.com/owncloud/client-desktop-shell-integration-nautilus/master/src/syncstate.py"
try:
urllib.request.urlretrieve(
URL, os.path.join(get_config('custom_lib'), 'syncstate.py')
)
except urllib.error.HTTPError as e:
raise Exception(
"Cannot download syncstate lib from"
+ "'owncloud/client-desktop-shell-integration-nautilus':\n"
+ e.read().decode()
)

# the script needs to use the system wide python
# to switch from the built-in interpreter see https://kb.froglogic.com/squish/howto/using-external-python-interpreter-squish-6-6/
# if the IDE fails to reference the script, add the folder in Edit->Preferences->PyDev->Interpreters->Libraries
sys.path.append(realpath('../../../shell_integration/nautilus/'))
# to switch from the built-in interpreter
# see https://kb.froglogic.com/squish/howto/using-external-python-interpreter-squish-6-6/
# if the IDE fails to reference the script,
# add the folder in Edit->Preferences->PyDev->Interpreters->Libraries
sys.path.append(custom_lib)
from syncstate import SocketConnect

from helpers.FilesHelper import sanitizePath
from helpers.ConfigHelper import get_config

# socket messages
socket_messages = []
Expand Down

0 comments on commit 9ab451a

Please sign in to comment.