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

Windows compatibility changes + Instructions #21

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion docs/config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ sync:
global-exclude:
- .DS_Store
- Thumbs.db
- desktop.ini

conflict-handling:
local-changes: ask
remote-deleted: ask

default-local-dir: /path/to/your/files/<name>/
default-local-dir: /path/to/your/files/<name>/ #E.g. /home/user/hsr/<name>/

repositories:
InfSi1:
remote-dir: Informatik/Fachbereich/Informationssicherheit_1_-_Grundlagen/InfSi1
exclude:
- '*.exe'
- 'Archiv'
OO:
remote-dir: Informatik\Fachbereich\Objektorientierte_Programmierung\OO

154 changes: 153 additions & 1 deletion docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,43 @@ Führe folgende Befehle als root aus!

## Für Linux-Distributionen:

###Sync
1. Install dependencies

```
$ sudo apt-get install git python3-setuptools gcc python3-dev libffi-dev libssl-dev python3-pip -y
```

2. Clone repo

```
$ git clone https://github.com/openhsr/connect.git
$ cd connect
```

3. Build & install

```
$ sudo python3 ./setup.py install
```

4. Set up sync settings

```
$ openhsr-connect edit
```

Enter HSR information, modify config file for your classes ([See example configuration](https://github.com/openhsr/connect/blob/master/docs/config.example.yaml))

5. Profit!

```
$ openhsr-connect sync
```

Sync the specified directories with the script server.


### Drucker
Damit CUPS das E-Mail-Backend nutzen kann muss dieses verlinkt werden.

Expand Down Expand Up @@ -42,7 +79,55 @@ if [ $? -eq 0 ]; then
lpadmin -x openhsr-connect
fi
```
## Für Mac OS X:
## Für macOS:

### Sync

1. Install [Homebrew](http://brew.sh/)

```
$/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
```


2. Install Python 3

```
$ brew install python3
```

3. Clone repo

```
$ git clone https://github.com/openhsr/connect.git
$ cd connect
```


4. Build & install

```
$ python3 ./setup.py install
```


5. Set up sync settings

```
$ openhsr-connect edit
```

Enter HSR information, modify config file for your classes ([See example configuration](https://github.com/openhsr/connect/blob/master/docs/config.example.yaml))
If you get a decoding error and the application crashes after entering your email address, make sure you have your encoding set to 'Western (ISO Latin 1)' and not UTF-8. You can change this setting under Terminal->Preferences->Profiles->Advanced->Text encoding.

6. Profit!

```
$ openhsr-connect sync
```

Sync the specified directories with the script server.

### Drucker
Damit CUPS das E-Mail-Backend nutzen kann muss dieses verlinkt werden.
```bash
Expand Down Expand Up @@ -75,3 +160,70 @@ if [ $? -eq 0 ]; then
lpadmin -x openhsr-connect
fi
```

##Für Windows (Not officially supported)

### Sync
1. Download Python 3.x

Latest is 3.5.2 as of creation of this guide. [Download website](https://www.python.org/downloads/release/python-352/), [Installer](https://www.python.org/ftp/python/3.5.2/python-3.5.2-amd64.exe))
Install and make sure to install the py launcher as well (this setting should automatically be set in the advanced installation options).

2. Install git

[Download link](https://git-scm.com/download/win)

3. Clone repo

Open admin command prompt

```
$ git clone https://github.com/openhsr/connect.git
$ cd connect
```


4. Build & install

```
$ py -3 setup.py install
```


5. Add Python Scripts folder to $PATH

For x64 Python this path is ```C:\Program Files\Python35\Scripts``` by default. If you're not sure how to add this to Path, check [this link](http://www.computerhope.com/issues/ch000549.htm)

6. Set up sync settings

```
$ openhsr-connect edit
```

Enter HSR information, modify config file for your classes (See example [here](https://github.com/openhsr/connect/blob/master/docs/config.example.yaml))

7. Profit!

```
$ openhsr-connect sync
```

Sync the specified directories with the script server.

##Bash on Ubuntu on Windows (Not officially supported)
### Sync
It's probably easier to just use it in Windows if you're on Windows but here's how you'd get it to work on BoUoW:

Follow steps 1-3 from the Ubuntu/Debian section, then:

Download & install keyrings.alt

```
$ cd
$ curl https://pypi.python.org/packages/27/d0/9207bf58de11735fe2239deaecb9eae1084e2887077a700ac8aa27bd8159/keyrings.alt-1.1.1.tar.gz | tar xz
$ cd keyrings.alt-1.1.1
$ sudo python3 ./setup.py install
```

Continue with step 4 from the Linux-Distributionen section.

22 changes: 21 additions & 1 deletion openhsr_connect/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import keyring
from .exceptions import PasswordException, ConfigurationException
import jsonschema
import errno

logger = logging.getLogger('openhsr_connect.config')
PATH_CONFIG = '~/.config/openhsr-connect.yaml'
Expand All @@ -19,6 +20,7 @@
global-exclude:
- .DS_Store
- Thumbs.db
- desktop.ini

conflict-handling:
local-changes: ask # ask | keep | overwrite | makeCopy
Expand Down Expand Up @@ -103,10 +105,27 @@ def create_default_config(config_path):
username = input('Dein HSR-Benutzername: ')
mail = input('Deine HSR-Email ([email protected]): ')
config = DEFAULT_CONFIG.format(username=username, mail=mail)
with open(config_path, 'w') as f:

Copy link
Contributor

Choose a reason for hiding this comment

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

Gemäss PEP-8 nur eine leere Zeile


with safe_open_w(config_path) as f:
f.write(config)


def safe_open_w(path):
Copy link
Contributor

Choose a reason for hiding this comment

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

Python Methodenkommentare sind unterhalb mit drei "
Also

def safe_open_w(path):
"""
Open file path and create parent directories if necessary as open() doesn't create them on Windows
"""

"""
Open file path and create parent directories if necessary as open() doesn't create them on Windows
"""
try:
os.makedirs(os.path.dirname(path))
except OSError as e:
if e.errno == errno.EEXIST and os.path.isdir(os.path.dirname(path)):
pass
else:
raise

return open(path, 'w')

Copy link
Contributor

Choose a reason for hiding this comment

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

Whitespace bitte löschen


def load_config(raise_if_incomplete=False):
"""
Loads the user configuration and creates the default configuration if it does not yet exist.
Expand All @@ -117,6 +136,7 @@ def load_config(raise_if_incomplete=False):
if not os.path.exists(config_path):
if raise_if_incomplete:
raise ConfigurationException('Configuration does not yet exist!')

create_default_config(config_path)

config = None
Expand Down