-
Notifications
You must be signed in to change notification settings - Fork 0
Mac compability #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mouuff
wants to merge
37
commits into
master
Choose a base branch
from
mac_compability
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
2aa53f6
It starts on macos, need to work on the desktop entries
peauc 87682be
added app bundle
lokoum d6ebc8c
The solution is now launched via iQuail on OSX
lokoum d35f3db
OSX - Started to work on a proper xml way of writing plist files
peauc ebcbfcd
Merge branch 'master' into mac_compability
lokoum 1af7eb6
Fixed some variables names
lokoum 8d491ee
Merge branch 'mac_compability' of https://github.com/QuailTeam/iQuail…
lokoum 67f9841
Fixed code from the feedback review
lokoum b563fd6
Removed a syntax error
peauc 206afa3
Fix bundle path
lokoum 95c6e94
Merge branch 'mac_compability' of https://github.com/QuailTeam/iQuail…
lokoum 6154eae
Adding a new feature to parse and write xml files for our OSX install.
peauc a19b6c8
Added new tests for our xml feature
peauc 310fe69
Hey we have icons on osx now -> Extra s in resource folder
peauc 7706633
d4c9dae
fixed wrong syntax on class declaration
peauc 2050428
fee4133
Auto stash before merge of "mac_compability" and "origin/master"
peauc 7d06807
Missing an S to the application's folder
peauc fae2ecc
Fixing some variable name and removing old comments
peauc 0ce224c
Added key/value adding in plcreator
peauc aea3b82
We are now creating valid .plist files
peauc 8532d48
Skipping IOS test on different platforms
peauc aed062d
removed an old file.
peauc 850ec11
Refactored the plist_creator.py file
peauc 96f2edf
Changed the error message when tkinter is not found
peauc b3c39e3
Added a todo
peauc 23e6dfe
Merge branch 'master' into mac_compability
lokoum 73f5bd9
Cleaned the installer OSX file and added local installation
peauc 8c9dd30
Cleaned the installer OSX file and added local installation
peauc 3239bcd
Refactoring
peauc 252a4b0
Made the ios import exclusive to ios
peauc f9a0ebc
Added support for user designed icon on the OSx installation
peauc fc6cae9
Merge branch 'mac_compability' of https://github.com/QuailTeam/iQuail…
lokoum 3332f31
added github full solution handling
peauc 83bd11d
fix bugs about PATH for local binaries, added eexample for PKG with GUI
lokoum 977c7ce
ready for merging with master
lokoum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,3 +109,6 @@ ENV/ | |
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
#Don't add mac's dsstore | ||
*.DS_Store* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"maccalc": "bdee4331072ce68954b7aa6d090165bc638474bf9515114a72d5baf86fa415af"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env bash | ||
open -a calculator && cat |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/python3 | ||
|
||
import iquail | ||
|
||
if iquail.helper.OS_OSX: | ||
solution_path = ['MacCalc'] | ||
iquail.run( | ||
iquail.SolutionLocal(['MacCalc']), | ||
iquail.Installer( | ||
name='MacCalc', | ||
publisher='test', | ||
icon='icon.icns', | ||
binary='maccalc', | ||
console=True, | ||
), | ||
iquail.builder.Builder(iquail.builder.CmdIntegrity(solution_path)) | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/python3 | ||
import os | ||
import iquail | ||
import logging | ||
|
||
|
||
logging.basicConfig( | ||
level=logging.DEBUG, | ||
filename=os.path.join(os.path.dirname(__file__), '..', 'iquail.log'), | ||
) | ||
|
||
if not iquail.helper.OS_OSX: | ||
raise AssertionError("This test solution is macOs only") | ||
|
||
|
||
class FrameSelectMiniOrFull(iquail.controller_tkinter.FrameBaseConfigure): | ||
def __init__(self, parent, controller): | ||
super().__init__(parent, controller) | ||
self.version_selected = self.add_combobox("Which version would you like to install?", | ||
('2.2.6', '2.2.6')) | ||
|
||
def next_pressed(self): | ||
print(self.version_selected.get()) | ||
version = self.version_selected.get().lower() | ||
zip = "cmder_mini.zip" if version == "mini" else "cmder.zip" | ||
self.manager.config.set("zip_url", zip) | ||
self.controller.switch_to_install_frame() | ||
|
||
iquail.run( | ||
solution=iquail.SolutionLocal(['Vagrant']), | ||
installer=iquail.Installer( | ||
publisher='HashiCorp', | ||
name='vagrant', | ||
icon='vagrant.pkg', | ||
binary='vagrant.pkg', | ||
console=False, | ||
launch_with_quail=True, | ||
), | ||
builder=iquail.builder.Builder( | ||
iquail.builder.CmdIcon('icon.ico'), | ||
iquail.builder.CmdNoconsole() | ||
), | ||
controller=iquail.ControllerTkinter( | ||
install_custom_frame=FrameSelectMiniOrFull), | ||
conf_ignore=["config/*"] | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
import sys | ||
|
||
from .controller_base import ControllerBase | ||
from .controller_tkinter import ControllerTkinter | ||
try: | ||
from .controller_tkinter import ControllerTkinter | ||
except ImportError as e: | ||
print(f"Tkinter not found....", file=sys.stderr) | ||
from .controller_console import ControllerConsole |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .bundle_template import BundleTemplate | ||
from .plist_creator import PlistCreator |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import os | ||
import shutil | ||
|
||
|
||
class BundleTemplate: | ||
def __init__(self, bundle_name: str, base_dir='/Applications'): | ||
self.full_path = os.path.join(base_dir, bundle_name + ".app") | ||
self.names = [ | ||
self.full_path, | ||
os.path.join(self.full_path, 'Contents'), | ||
os.path.join(self.full_path, 'Contents/MacOS'), | ||
os.path.join(self.full_path, 'Contents/Resources') | ||
] | ||
def installIcon(self, icon_file_name, icon_quail_path): | ||
dest_path = os.path.join(self.full_path, 'Contents/Resources', icon_file_name) | ||
try: | ||
shutil.copy(icon_quail_path, dest_path) | ||
except FileNotFoundError as e: | ||
print("Error icon file {} was not found when installing".format(icon_quail_path)) | ||
|
||
|
||
def make(self): | ||
for path in self.names: | ||
os.mkdir(path) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import os | ||
import xml.etree.ElementTree as ET | ||
|
||
|
||
class PlistCreator: | ||
def __init__(self, bundle_name: str, application_path: str, plist_dict=None): | ||
# The argument plist_dict can't be mutable | ||
if not plist_dict: | ||
plist_dict = {} | ||
self.__filename = os.path.join(application_path, bundle_name + ".app/Contents/Info.plist") | ||
self.__data = "" | ||
self.__plist_dict = { | ||
"CFBundleGetInfoString": bundle_name, | ||
"CFBundleExecutable": 'launcher', | ||
"CFBundleIdentifier": bundle_name, | ||
"CFBundleName": bundle_name | ||
} | ||
self.__plist_header = """ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
""" | ||
self.__plist_dict.update(plist_dict) | ||
|
||
@property | ||
def plist_dict(self): | ||
return self.__plist_dict | ||
|
||
def __make_key_with_text(self, key: str, value: str): | ||
item = ET.Element(key) | ||
item.text = value | ||
return item | ||
|
||
def __indent_tree(self, elem, level=0): | ||
i = "\n" + level * " " | ||
if len(elem): | ||
if not elem.text or not elem.text.strip(): | ||
elem.text = i + " " | ||
if not elem.tail or not elem.tail.strip(): | ||
elem.tail = i | ||
for elem in elem: | ||
self.__indent_tree(elem, level + 1) | ||
if not elem.tail or not elem.tail.strip(): | ||
elem.tail = i | ||
else: | ||
if level and (not elem.tail or not elem.tail.strip()): | ||
elem.tail = i | ||
|
||
def __add_icon(self, root: ET.Element, icon_name: str): | ||
root.append(self.__make_key_with_text('key', 'CFBundleIconFile')) | ||
root.append(self.__make_key_with_text('string', icon_name)) | ||
|
||
def __create_tree(self) -> ET.Element: | ||
root = ET.Element('plist', {'version':'1.0'}) | ||
return root | ||
|
||
def build_tree_and_write_file(self): | ||
tree = self.__create_tree() | ||
|
||
self.__data += self.__plist_header | ||
self.__add_dict_content_to_tree(tree) | ||
self.__indent_tree(tree) | ||
self.__write_to_file(tree) | ||
|
||
def __add_dict_content_to_tree(self, root: ET.Element): | ||
elem = ET.Element('dict') | ||
for key, value in self.plist_dict.items(): | ||
elem.append(self.__make_key_with_text('key', key)) | ||
elem.append(self.__make_key_with_text('string', value)) | ||
root.append(elem) | ||
|
||
def __write_to_file(self, tree): | ||
tree_data = ET.tostring(tree, encoding='unicode') | ||
with open(self.__filename, 'w+') as f: | ||
total_data = self.__data + tree_data | ||
f.write(total_data) | ||
|
||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
from .installer_base import InstallerBase | ||
import os | ||
import stat | ||
import shutil | ||
import pathlib | ||
from ..helper import BundleTemplate, PlistCreator | ||
|
||
class InstallerOsx(InstallerBase): | ||
|
||
def __init__(self, full_app, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self._bundle_install_path = os.path.join(self._get_application_folder_path(), self.name + '.app') | ||
self.is_full_app = full_app | ||
|
||
""" TODO: Add the icon to the bundle""" | ||
def _register(self): | ||
if (self._should_register_as_pkg()): | ||
self._register_as_pkg() | ||
return | ||
if self.is_full_app: | ||
shutil.copytree(self.binary, os.path.join(self._get_application_folder_path(), self._binary_name)) | ||
launcher_path = os.path.join(self._bundle_install_path, 'Contents', 'MacOS', self.name) | ||
st = os.stat(launcher_path) | ||
os.chmod(launcher_path, st.st_mode | stat.S_IEXEC) | ||
return | ||
else: | ||
bundle = BundleTemplate(self.name, base_dir=self._get_application_folder_path()) | ||
icon_quail_path = self.get_solution_icon() | ||
bundle.make() | ||
if self._icon: | ||
bundle.installIcon(self._icon, icon_quail_path) | ||
plist = PlistCreator(self.name, self._get_application_folder_path(), {'CFBundleIconFile': self._icon}) | ||
plist.build_tree_and_write_file() | ||
self._build_launcher() | ||
|
||
def _unregister(self): | ||
if (self._should_register_as_pkg()): | ||
#self._register_as_pkg() | ||
return | ||
shutil.rmtree(self._bundle_install_path) | ||
|
||
def _registered(self): | ||
if not os.path.exists(self.build_folder_path(self.binary)): | ||
return False | ||
return True | ||
|
||
def __add_to_path(self, binary, name): | ||
os.symlink(binary, self.build_folder_path(name)) | ||
|
||
def _get_application_folder_path(self): | ||
if self.install_systemwide: | ||
return os.path.join(os.sep, 'Applications') | ||
return os.path.join(str(pathlib.Path.home()), 'Applications') | ||
|
||
def _should_register_as_pkg(self): | ||
if (self.binary.lower().endswith(".pkg")): | ||
return True | ||
return False | ||
|
||
def _register_as_pkg(self): | ||
path = os.path.join(self._solution_path, self.binary) | ||
pkg_installation = "installer -pkg " + path + " -target /" | ||
print(path) | ||
print(pkg_installation) | ||
os.system("/usr/bin/osascript -e 'do shell script \"" + pkg_installation + "\" with administrator privileges'") | ||
|
||
def build_folder_path(self, name): | ||
final_folder = os.path.join(self._get_application_folder_path(), self._name + '.app', 'Contents', 'MacOS') | ||
return os.path.join(final_folder, name) | ||
|
||
def _build_launcher(self): | ||
with open(os.path.join(self._bundle_install_path, 'Contents', 'MacOS', 'launcher'), 'w') as f: | ||
shebang = '#!/usr/bin/env bash\n' | ||
content = '/usr/bin/env python3 ' + self.launcher_binary | ||
f.write(shebang) | ||
f.write(content) | ||
st = os.stat(os.path.join(self._bundle_install_path, 'Contents', 'MacOS', 'launcher')) | ||
os.chmod(os.path.join(self._bundle_install_path, 'Contents', 'MacOS', 'launcher'), st.st_mode | stat.S_IEXEC) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import iquail.helper | ||
|
||
if iquail.helper.OS_OSX: | ||
import shutil | ||
|
||
peauc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
from tests.base_test_case import BaseTestCase | ||
from iquail.helper.osx.bundle_template import BundleTemplate | ||
from iquail.helper.osx.plist_creator import PlistCreator | ||
|
||
|
||
class BaseTestOsxBundle(BaseTestCase): | ||
# The test folder will always be named test.app | ||
def setUp(self): | ||
super(BaseTestOsxBundle, self).setUp() | ||
self._test_folder_path = self.tmp('test.app') | ||
self.bt = BundleTemplate('test', self._tmpdir) | ||
self.bt.make() | ||
|
||
def tearDown(self): | ||
shutil.rmtree(self.bt.full_path, ignore_errors=True) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.