Skip to content

Commit

Permalink
python3 support. remove python2 compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoxinghuo committed Mar 18, 2022
1 parent 0982b61 commit b364f4f
Show file tree
Hide file tree
Showing 19 changed files with 1,345 additions and 2,742 deletions.
65 changes: 32 additions & 33 deletions ConnectionSearcher.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
#! /usr/bin/python
#!/usr/local/bin/python3
# -*- coding: utf-8 -*-

from lib import biplist
import os
import json
import sys
import glob
import plistlib
from workflow import Workflow, ICON_WARNING, MATCH_SUBSTRING

reload(sys)
sys.setdefaultencoding('utf8')


def read_connections():
# Read preferences file
preferencesPath = os.path.join(os.environ["HOME"], "Library", "Containers", "com.p5sys.jump.mac.viewer", "Data", "Library", "Preferences", "com.p5sys.jump.mac.viewer.plist")
preferences_path = os.path.join(os.environ["HOME"], "Library", "Containers", "com.p5sys.jump.mac.viewer", "Data", "Library", "Preferences", "com.p5sys.jump.mac.viewer.plist")
# if preference path not exists, try this location:
if not os.path.isfile(preferencesPath):
preferencesPath = os.path.join(os.environ["HOME"], "Library", "Preferences", "com.p5sys.jump.mac.viewer.web.plist")
plist = biplist.readPlist(preferencesPath)
# Extract profile data from plist
connectionPath = plist.get('path where JSON .jump files are stored')
if connectionPath.startswith('~'):
connectionPath = os.environ["HOME"] + connectionPath[1:]
jumps = glob.glob(connectionPath + "/Computer - *.jump")
if not os.path.isfile(preferences_path):
preferences_path = os.path.join(os.environ["HOME"], "Library", "Preferences", "com.p5sys.jump.mac.viewer.web.plist")

connections = []
for jump in jumps:
f = open(jump)
json_content = f.read()
f.close()
dict_content = json.loads(json_content)
icon = None
if dict_content['Icon']:
icon = "/Applications/Jump Desktop.app/Contents/Resources/%s.png" % dict_content['Icon']
command = 'jump://?protocol=%s&host=%s&username=%s' % \
(protocol_switch(dict_content['ProtocolTypeCode']), dict_content['TcpHostName'], dict_content['Username'])

connections.append({
'name': dict_content['DisplayName'],
'command': command,
'path': jump,
'icon': icon,
'tags': dict_content['Tags']
})
with open(preferences_path, 'rb') as fp:
plist = plistlib.load(fp)
# Extract profile data from plist
connection_path = plist.get('path where JSON .jump files are stored')
if connection_path.startswith('~'):
connection_path = os.environ["HOME"] + connection_path[1:]
jumps = glob.glob(connection_path + "/Computer - *.jump")
connections = []
for jump in jumps:
f = open(jump)
json_content = f.read()
f.close()
dict_content = json.loads(json_content)
icon = None
if dict_content['Icon']:
icon = "/Applications/Jump Desktop.app/Contents/Resources/%s.png" % dict_content['Icon']
command = 'jump://?protocol=%s&host=%s&username=%s' % \
(protocol_switch(dict_content['ProtocolTypeCode']), dict_content['TcpHostName'], dict_content['Username'])

connections.append({
'name': dict_content['DisplayName'],
'command': command,
'path': jump,
'icon': icon,
'tags': dict_content['Tags']
})

return connections

Expand Down Expand Up @@ -91,4 +91,3 @@ def main(wf):
if __name__ == u"__main__":
wf = Workflow()
sys.exit(wf.run(main))

Empty file removed lib/__init__.py
Empty file.
8 changes: 0 additions & 8 deletions lib/biplist-1.0.1.dist-info/DESCRIPTION.rst

This file was deleted.

1 change: 0 additions & 1 deletion lib/biplist-1.0.1.dist-info/INSTALLER

This file was deleted.

26 changes: 0 additions & 26 deletions lib/biplist-1.0.1.dist-info/METADATA

This file was deleted.

9 changes: 0 additions & 9 deletions lib/biplist-1.0.1.dist-info/RECORD

This file was deleted.

5 changes: 0 additions & 5 deletions lib/biplist-1.0.1.dist-info/WHEEL

This file was deleted.

1 change: 0 additions & 1 deletion lib/biplist-1.0.1.dist-info/metadata.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/biplist-1.0.1.dist-info/top_level.txt

This file was deleted.

Loading

0 comments on commit b364f4f

Please sign in to comment.