Skip to content

Commit

Permalink
Merge pull request #14 from kliment/master
Browse files Browse the repository at this point in the history
Pull newest updates from Kliment
  • Loading branch information
DivingDuck authored Feb 1, 2021
2 parents ab934c9 + 5d83a83 commit 15d6981
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 34 deletions.
24 changes: 18 additions & 6 deletions .github/workflows/buildpackage-mac.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Mac OS X app
name: Build macOS app

on:
push:
Expand Down Expand Up @@ -34,15 +34,27 @@ jobs:
- name: Make pyinstaller spec
run: |
pyi-makespec --hidden-import="pkg_resources.py2_warn" -F --add-data images/\*:images --add-data \*.png:. --add-data \*.ico:. -w -i P-face.icns pronterface.py
# Edit spec file
export git_hash=$(git rev-parse --short "$GITHUB_SHA")
sed -i '' '$ s/.$//' pronterface.spec
cat >> pronterface.spec <<EOL
,
info_plist={
'CFBundleShortVersionString': '$git_hash',
'NSPrincipalClass': 'NSApplication',
'NSAppleScriptEnabled': False,
'NSAppSleepDisabled': True,
},
)
EOL
- name: Make pyinstaller build
run: |
pyinstaller --clean pronterface.spec -y
ls -l dist/pronterface.app/Contents/macOS/pronterface
chmod +x dist/pronterface.app/Contents/macOS/pronterface
ls -l dist/pronterface.app/Contents/macOS/pronterface
zip -r -X pronterface-app.zip dist
# Zip app manually to avoid losing execute permissions for binary file in app
cd dist
zip -r -X pronterface-app.zip pronterface.app
- name: Upload artifacts for inspection
uses: actions/upload-artifact@v2
with:
name: macosapp_${{ matrix.os }}_${{ matrix.architecture }}_${{ matrix.python-version }}
path: pronterface-app.zip
path: dist/pronterface-app.zip
2 changes: 1 addition & 1 deletion .github/workflows/pypi-mac.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Mac OS X Python package
name: Build macOS Python package

on:
push:
Expand Down
40 changes: 24 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,29 @@ If you want the newest, shiniest features, you can run Printrun from source usin

## Windows

A precompiled version is available at http://koti.kapsi.fi/~kliment/printrun/
A precompiled version is available at https://github.com/kliment/Printrun/releases

## Mac OS X
## MacOS

A precompiled version is available at http://koti.kapsi.fi/~kliment/printrun/
A precompiled version is available at https://github.com/kliment/Printrun/releases

Note for OSX users: if OSX tells you the file is corrupted, you don't need to redownload it. Instead, you need to allow OSX to run unsigned apps. To do this, run
`sudo spctl --master-disable`
Note for OSX users: if OSX tells you `"pronterface.app" cannot be opened because the developer cannot be verified.`, you don't need to redownload it. Instead, you need to allow OSX to run the unsigned app. To do this, right click the application in Finder and select `Open`. Then click `Open` in the popup window that appears. You only need to do this once.


## Linux
### Ubuntu/Debian

There is currently no package for Printrun 2. It must be [run from source](https://github.com/kliment/Printrun/tree/master#running-from-source).

### Chrome OS
### Chrome OS

You can use Printrun via crouton ( https://github.com/dnschneid/crouton ). Assuming you want Ubuntu Trusty, you used probably `sudo sh -e ~/Downloads/crouton -r trusty -t xfce` to install Ubuntu. Fetch and install printrun with the line given above for Ubuntu/Debian.

By default you have no access to the serial port under Chrome OS crouton, so you cannot connect to your 3D printer. Add yourself to the serial group within the linux environment to fix this

`sudo usermod -G serial -a <username>`
`sudo usermod -G serial -a <username>`

where `<username>` should be your username. Log out and in to make this group change active and allow communication with your printer.
where `<username>` should be your username. Log out and in to make this group change active and allow communication with your printer.

### Fedora

Expand Down Expand Up @@ -79,12 +78,12 @@ To use pronterface, you need:
* numpy (for 3D view)
* pycairo (to use Projector feature)
* cairosvg (to use Projector feature)
* dbus (to inhibit sleep on some Linux systems)
* dbus (to inhibit sleep on some Linux systems)

### Use Python virtual environment

Easiest way to run Printrun from source is to create and use a Python [virtual environment](https://docs.python.org/3/tutorial/venv.html).
The following section assumes Linux. Please see specific instructions for Windows and macOS X below.
The following section assumes Linux. Please see specific instructions for Windows and macOS below.

**Ubuntu/Debian note:** You might need to install `python3-venv` first.

Expand Down Expand Up @@ -149,15 +148,25 @@ Download and install [Python 3.6](https://www.python.org/downloads/) and follow
```


### macOS X
### macOS

Install Python 3, you can use Brew:

```console
$ brew install python3
```

And follow the above **Python virtual environment** section. You don't need to search for wxPython wheel, macOS wheels are available from the Python Package Index.
Then continue to install and set up Printrun:

```console
$ git clone https://github.com/kliment/Printrun.git # clone the repository
$ cd Printrun # change to Printrun directory
$ python3 -m venv venv # create an virtual environment
$ . venv/bin/activate # activate the virtual environment (notice the space after the dot)
(venv) $ python -m pip install -r requirements.txt # install the rest of dependencies
# follow instructions for cython gcoder here if desired
(venv) $ python pronterface.py # run Pronterface
```


# USING PRINTRUN
Expand Down Expand Up @@ -393,15 +402,15 @@ For example, following macro toggles the diagnostic information similarily to th

Macro parameters are available in '!'-escaped python code as locally defined list variable: arg[0] arg[1] ... arg[N]

All python code is executed in the context of the pronsole (or PronterWindow) object,
All python code is executed in the context of the pronsole (or PronterWindow) object,
so it is possible to use all internal variables and methods, which provide great deal of functionality.
However the internal variables and methods are not very well documented and may be subject of change, as the program is developed.
Therefore it is best to use pronsole commands, which easily contain majority of the functionality that might be needed.

Some useful python-mode-only variables:

```python
!self.settings - contains all settings, e.g.
!self.settings - contains all settings, e.g.
port (!self.settings.port), baudrate, xy_feedrate, e_feedrate, slicecommand, final_command, build_dimensions
You can set them also via pronsole command "set", but you can query the values only via python code.
!self.p - printcore object (see USING PRINTCORE section for using printcore object)
Expand All @@ -412,7 +421,7 @@ Some useful python-mode-only variables:
Some useful methods:

```python
!self.onecmd - invokes raw command, e.g.
!self.onecmd - invokes raw command, e.g.
!self.onecmd("move x 10")
!self.onecmd("!print self.p.loud")
!self.onecmd("button "+self.cur_button+" fanOFF /C cyan M107")
Expand Down Expand Up @@ -484,4 +493,3 @@ along with Printrun. If not, see <http://www.gnu.org/licenses/>.
```

All scripts should contain this license note, if not, feel free to ask us. Please note that files where it is difficult to state this license note (such as images) are distributed under the same terms.

17 changes: 11 additions & 6 deletions buildinstructions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@ python pronterface.py

for packaging:
pip install pyinstaller
pyi-makespec -F --add-data images/\*:images --add-data \*.png:. --add-data \*.ico:. -w -i P-face.icns pronterface.py
pyi-makespec --hidden-import="pkg_resources.py2_warn" -F --add-data images/\*:images --add-data \*.png:. --add-data \*.ico:. -w -i P-face.icns pronterface.py
rm -rf dist
pyinstaller --clean pronterface.spec -y
(edit .plist file to add:
<key>NSAppSleepDisabled</key>
<true/>
sed -i '' '$ s/.$//' pronterface.spec
cat >> pronterface.spec <<EOL
,
info_plist={
'NSPrincipalClass': 'NSApplication',
'NSAppleScriptEnabled': False,
'NSAppSleepDisabled': True,
},
)
EOL
pyinstaller --clean pronterface.spec -y
(optional) codesign -s identityname dist/pronterface.app --deep

setup on windows:
Expand All @@ -51,4 +57,3 @@ for packaging:
pip install pyinstaller
pyi-makespec -F --add-data images/*;images --add-data *.png;. --add-data *.ico;. -w -i pronterface.ico pronterface.py
pyinstaller --clean pronterface.spec -y

19 changes: 14 additions & 5 deletions printrun/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.

import os
import platform
import sys
import re
import gettext
Expand All @@ -39,12 +40,20 @@ def install_locale(domain):
shared_locale_dir = os.path.join(DATADIR, 'locale')
translation = None
lang = locale.getdefaultlocale()

if os.path.exists('./locale'):
translation = gettext.translation(domain, './locale', languages=[lang[0]], fallback= True)
osPlatform = platform.system()

if osPlatform == "Darwin":
# improvised workaround for macOS crash with gettext.translation, see issue #1154
if os.path.exists(shared_locale_dir):
gettext.install(domain, shared_locale_dir)
else:
gettext.install(domain, './locale')
else:
translation = gettext.translation(domain, shared_locale_dir, languages=[lang[0]], fallback= True)
translation.install()
if os.path.exists('./locale'):
translation = gettext.translation(domain, './locale', languages=[lang[0]], fallback= True)
else:
translation = gettext.translation(domain, shared_locale_dir, languages=[lang[0]], fallback= True)
translation.install()

class LogFormatter(logging.Formatter):
def __init__(self, format_default, format_info):
Expand Down

0 comments on commit 15d6981

Please sign in to comment.