Skip to content
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

Mac compability #8

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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 Jan 24, 2019
87682be
added app bundle
lokoum Jan 29, 2019
d6ebc8c
The solution is now launched via iQuail on OSX
lokoum Mar 25, 2019
d35f3db
OSX - Started to work on a proper xml way of writing plist files
peauc Mar 26, 2019
ebcbfcd
Merge branch 'master' into mac_compability
lokoum Mar 26, 2019
1af7eb6
Fixed some variables names
lokoum Mar 26, 2019
8d491ee
Merge branch 'mac_compability' of https://github.com/QuailTeam/iQuail…
lokoum Mar 26, 2019
67f9841
Fixed code from the feedback review
lokoum Mar 26, 2019
b563fd6
Removed a syntax error
peauc Mar 26, 2019
206afa3
Fix bundle path
lokoum Mar 27, 2019
95c6e94
Merge branch 'mac_compability' of https://github.com/QuailTeam/iQuail…
lokoum Mar 27, 2019
6154eae
Adding a new feature to parse and write xml files for our OSX install.
peauc Apr 22, 2019
a19b6c8
Added new tests for our xml feature
peauc Apr 22, 2019
310fe69
Hey we have icons on osx now -> Extra s in resource folder
peauc Apr 23, 2019
7706633
Forgot to commit the file (Couldn't ammend don't know why)
peauc Apr 23, 2019
d4c9dae
fixed wrong syntax on class declaration
peauc Apr 23, 2019
2050428
Merging master from mac_compatibility
peauc Oct 23, 2019
fee4133
Auto stash before merge of "mac_compability" and "origin/master"
peauc Oct 23, 2019
7d06807
Missing an S to the application's folder
peauc Oct 24, 2019
fae2ecc
Fixing some variable name and removing old comments
peauc Oct 24, 2019
0ce224c
Added key/value adding in plcreator
peauc Oct 24, 2019
aea3b82
We are now creating valid .plist files
peauc Oct 24, 2019
8532d48
Skipping IOS test on different platforms
peauc Oct 24, 2019
aed062d
removed an old file.
peauc Oct 24, 2019
850ec11
Refactored the plist_creator.py file
peauc Oct 24, 2019
96f2edf
Changed the error message when tkinter is not found
peauc Oct 24, 2019
b3c39e3
Added a todo
peauc Oct 24, 2019
23e6dfe
Merge branch 'master' into mac_compability
lokoum Dec 9, 2019
73f5bd9
Cleaned the installer OSX file and added local installation
peauc Dec 11, 2019
8c9dd30
Cleaned the installer OSX file and added local installation
peauc Dec 11, 2019
3239bcd
Refactoring
peauc Dec 11, 2019
252a4b0
Made the ios import exclusive to ios
peauc Dec 11, 2019
f9a0ebc
Added support for user designed icon on the OSx installation
peauc Dec 11, 2019
fc6cae9
Merge branch 'mac_compability' of https://github.com/QuailTeam/iQuail…
lokoum Dec 12, 2019
3332f31
added github full solution handling
peauc Dec 12, 2019
83bd11d
fix bugs about PATH for local binaries, added eexample for PKG with GUI
lokoum Dec 12, 2019
977c7ce
ready for merging with master
lokoum Dec 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/MacCalc/.integrity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"maccalc": "bdee4331072ce68954b7aa6d090165bc638474bf9515114a72d5baf86fa415af"}
2 changes: 2 additions & 0 deletions examples/MacCalc/maccalc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
open -a calculator && cat
13 changes: 13 additions & 0 deletions examples/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@
iquail.builder.CmdIntegrity(solution_path)
)
)
if iquail.helper.OS_OSX:
solution_path = ['Allum1']
iquail.run(
iquail.SolutionLocal(['Allum1']),
iquail.Installer(
name='Allum1',
publisher='alies',
icon='icon.jpeg',
binary='allum1',
console=True,
),
iquail.builder.Builder(iquail.builder.CmdIntegrity(solution_path))
)
if iquail.helper.OS_WINDOWS:
solution_path = ['OpenHardwareMonitor']
iquail.run(
Expand Down
20 changes: 20 additions & 0 deletions examples/test_osx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/python3

import os
import os.path
import iquail
import platform

if iquail.helper.OS_OSX:
solution_path = ['MacCalc']
iquail.run(
iquail.SolutionLocal(['MacCalc']),
iquail.Installer(
name='MacCalc',
publisher='test',
icon='icon.jpeg',
binary='maccalc',
console=True,
),
iquail.builder.Builder(iquail.builder.CmdIntegrity(solution_path))
)
5 changes: 4 additions & 1 deletion iquail/controller/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from .controller_base import ControllerBase
from .controller_tkinter import ControllerTkinter
try:
from .controller_tkinter import ControllerTkinter
except:
print("No display found or tkinter missing, console mode enabled !")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Le problème c'est que si on importe pas, plus pas il y aura une ref non trouvé, et aussi les args de controller_tkinter sont pas les mêmes que controller console, donc c'est pas vraiment interchangeable pour le moment

from .controller_console import ControllerConsole
1 change: 1 addition & 0 deletions iquail/helper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
from .file_ignore import FileIgnore, accept_path
from .integrity_verifier import IntegrityVerifier, checksum_file
from .configuration import Configuration, ConfVar
from .osx import BundleTemplate, PlistTemplate
1 change: 1 addition & 0 deletions iquail/helper/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

OS_LINUX = platform.system() == 'Linux'
OS_WINDOWS = platform.system() == 'Windows'
OS_OSX = platform.system() == 'Darwin'


def cache_result(func):
Expand Down
2 changes: 2 additions & 0 deletions iquail/helper/osx/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .bundle_template import BundleTemplate
from .plist_template import PlistTemplate
14 changes: 14 additions & 0 deletions iquail/helper/osx/bundle_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os

class BundleTemplate():

def __init__(self, CFBundleName):
self.bundle_name = CFBundleName
#TODO refactor name
self.base_dir = "/Applications/"
self.full_path = self.base_dir + self.bundle_name + ".app"
self.names = [self.full_path, self.full_path + "/Contents", self.full_path + "/Contents/MacOS"]

def make(self):
for path in self.names:
os.mkdir(path)
33 changes: 33 additions & 0 deletions iquail/helper/osx/plist_creator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import xml.etree.ElementTree as ET

class PlistCreator:
def __init__(self, bundle_name: str, plistDict: dict):
self.__file = open("/applications/" + bundle_name + ".app/contents/info.plist", "a+")
self.__
peauc marked this conversation as resolved.
Show resolved Hide resolved
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">
<plist version="1.0">
"""
self.__plist_dict.update(plistDict)

def __del__(self):
self.__file.close()

@property
def plist_dict(self):
return self.__plist_dict

def write_file(self):
self.__create_header()

def __create_header(self):
self.__file.write(self.__plist_header)


42 changes: 42 additions & 0 deletions iquail/helper/osx/plist_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import os

#TODO : add full PATH to spotlight env to access python3
class PlistTemplate():
def __init__(self, CFBundleName, plistDict):
self.file = open("/Applications/" + CFBundleName + ".app/Contents/Info.plist", "a+")
self.plist_dict = dict(
CFBundleGetInfoString=CFBundleName,
CFBundleExecutable='launcher',
CFBundleIdentifier=CFBundleName,
CFBundleName=CFBundleName
)
self.plist_dict.update(plistDict)

def make(self):
self._createHeader()
for key, value in self.plist_dict.items():
self._writeProperty(key, value, "string")
self._createFooter()

def getInfoPlist(self):
return self.plist_dict

def _createHeader(self):
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">
<plist version="1.0">
<dict>
"""
self.file.write(self.plist_header)

def _createFooter(self):
self.plist_footer = """
</dict>
</plist>
"""
self.file.write(self.plist_footer)

def _writeProperty(self, key, value, typeValue):
self.file.write(" <key>" + key + "</key>\n")
self.file.write(" <" + typeValue + ">" + value + "</" + typeValue + ">\n")
4 changes: 3 additions & 1 deletion iquail/installer/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
from .installer_windows import InstallerWindows
Installer = InstallerWindows
else:
raise NotImplementedError
from .installer_osx import InstallerOsx
Installer = InstallerOsx

52 changes: 52 additions & 0 deletions iquail/installer/installer_osx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from .installer_base import InstallerBase
import os
import stat
import shutil
import pathlib
from ..helper import BundleTemplate, PlistTemplate

class InstallerOsx(InstallerBase):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._bundle_install_path = '/Applications/' + self.name + '.app'

""" We need to put a syslink into /usr/local/bin or into a local folder inside the user's home directory"""
def _register(self):
bundle = BundleTemplate(self._name)
bundle.make()
plist = PlistTemplate(self._binary_name, {})
peauc marked this conversation as resolved.
Show resolved Hide resolved
plist.make()
self._build_launcher()
#self.__add_to_path(self.binary, self._binary_name)

def _unregister(self):
self.__remove_from_path(self.binary)

def _registered(self):
if not os.path.exists(self.build_symlink_path(self.binary)):
return False

def __add_to_path(self, binary, name):
os.symlink(binary, self.build_symlink_path(name))
peauc marked this conversation as resolved.
Show resolved Hide resolved

def __remove_from_path(self, name):
peauc marked this conversation as resolved.
Show resolved Hide resolved
shutil.rmtree(self._bundle_install_path)

def build_symlink_path(self, name):
if self.install_systemwide:
#TODO setup local installation
#final_folder = '/Applications'
final_folder = os.path.join(str(pathlib.Path.home()), '/Applications/' + self._name + '.app/Contents/MacOS/')
peauc marked this conversation as resolved.
Show resolved Hide resolved
else:
final_folder = os.path.join(str(pathlib.Path.home()), '/Applications/' + self._name + '.app/Contents/MacOS/')
return os.path.join(final_folder, name)

def _build_launcher(self):
with open(self._bundle_install_path + '/Contents/MacOS/launcher', 'w') as f:
content = '/usr/local/bin/python3 ~/.iquail/' + self.uid + '/iquail_launcher.py'
peauc marked this conversation as resolved.
Show resolved Hide resolved
shebang = '#!/bin/bash\n'
f.write(shebang)
f.write(content)
st = os.stat(self._bundle_install_path + '/Contents/MacOS/launcher')
os.chmod(self._bundle_install_path + '/Contents/MacOS/launcher', st.st_mode | stat.S_IEXEC)
peauc marked this conversation as resolved.
Show resolved Hide resolved