-
Notifications
You must be signed in to change notification settings - Fork 2
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
seroam
wants to merge
22
commits into
openhsr:master
Choose a base branch
from
seroam:master
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
22 commits
Select commit
Hold shift + click to select a range
6e90eab
Add desktop.ini to global-exclude in default config to .DS_Store)
seroam dd81c45
Add function safe_open_w in configuration.py to create parent directo…
seroam 8aaaa94
Fix in safe_open_w
seroam 930ddf0
Modify docs/config.example.yaml for better example, included desktop.ini
seroam 2edf563
Add 'How to install' for Ubuntu/Debian section to README.md
seroam 25ae0cb
Edit formatting of How to install
seroam c236815
Edit text of README.md
seroam e578cf8
Edit text README.md
seroam 4ae950b
Add 'How to install' Windows part
seroam 7a76f03
Add 'Bash on Ubuntu on Windows' section, Text fixes
seroam 4f25439
Change links from seroam to openhsr
seroam 11302d4
Add section macOS to installation guides
seroam 4bdbb15
Add missing '$'
seroam 31668f8
Add spaces for enumeration
seroam 04f0346
Add more spaces for enumeration
seroam 552fadc
Change link format
seroam a829f5c
Change formatting
seroam 04b98c3
Edit formatting
seroam 7c49c6e
Edit formatting
seroam 075e8d0
Edit formatting
seroam e6893a7
Move install section to docs/install.md
seroam 4f64a98
Text fix
seroam 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 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 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 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 |
---|---|---|
|
@@ -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' | ||
|
@@ -19,6 +20,7 @@ | |
global-exclude: | ||
- .DS_Store | ||
- Thumbs.db | ||
- desktop.ini | ||
|
||
conflict-handling: | ||
local-changes: ask # ask | keep | overwrite | makeCopy | ||
|
@@ -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: | ||
|
||
|
||
with safe_open_w(config_path) as f: | ||
f.write(config) | ||
|
||
|
||
def safe_open_w(path): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Python Methodenkommentare sind unterhalb mit drei " 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') | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
@@ -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 | ||
|
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.
There was a problem hiding this comment.
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