Skip to content

Commit

Permalink
Replace CircleCi with Travis CI (#15)
Browse files Browse the repository at this point in the history
* Delete CircleCi config

* Add TravisCi config

* Fix indentation

* Remove pylint

* Fix PEP8 errors

* Add Codeclimate configuration

* Add Coveralls
  • Loading branch information
otherguy authored Oct 14, 2019
1 parent c2d3827 commit 88200c1
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 111 deletions.
45 changes: 0 additions & 45 deletions .circleci/config.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: "2"
plugins:
git-legal:
enabled: true
fixme:
enabled: true
sonar-python:
enabled: true
config:
tests_patterns:
- tests/**
pylint:
enabled: true
channel: "beta"
editorconfig:
enabled: true
channel: beta
config:
editorconfig: .editorconfig
checks:
similar-code:
enabled: false
identical-code:
enabled: false
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ end_of_line = lf
charset = utf-8

[*.py]
indent_size = 4
max_line_length = 160

[*.json]
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ __pycache__/
/workflow
/Alfred_Workflow-*
*.alfredworkflow
.coverage
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
language: python

python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"

env:
global:
# This is a write-only ID that can only post test reports.
- CC_TEST_REPORTER_ID=b8cbd5fee1ea6bd07ec2941a31efdac0b94388f5a4a9498a2605eb1e59b2fcf2
- COVERALLS_REPO_TOKEN=97gr8Jdu5WXrcer1UmmGAQeG4C9AH9V8b
- GIT_COMMITTED_AT=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then git log -1 --pretty=format:%ct; else git log -1 --skip 1 --pretty=format:%ct; fi)

install:
- pip install -r requirements.txt
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build

script:
- coverage run --branch -m unittest discover --start-directory tests

after_success:
- travis_retry coveralls
134 changes: 68 additions & 66 deletions pwgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,85 +5,87 @@
from workflow import Workflow3 as Workflow, ICON_INFO

def main(wf):
# Imports go here.
from xkcdpass import xkcd_password as xp
import string
from random import SystemRandom
# Imports go here.
from xkcdpass import xkcd_password as xp
import string
from random import SystemRandom

def genpw(size, chars):
return ''.join(SystemRandom().choice(chars) for _ in range(size))
def genpw(size, chars):
return ''.join(SystemRandom().choice(chars) for _ in range(size))

# Defaults
defaults = {
'password_length': 10,
'xkcd_delimiter': '-',
'xkcd_minlength': 4,
'xkcd_maxlength': 10,
'xkcd_wordllist': 'eff-long', # eff-long (English), spa-mich (Spanish), fin-kotus (Finnish),ita-wiki (Italian), ger-anlx (German)
}
# Defaults
defaults = {
'password_length': 10,
'xkcd_delimiter': '-',
'xkcd_minlength': 4,
'xkcd_maxlength': 10,
'xkcd_wordllist': 'eff-long', # eff-long (English)
}

# ================================= MAIN ===================================
# =============================== MAIN =================================

# Get args from Workflow, already in normalized Unicode
password_length = defaults['password_length']
if len(wf.args) >= 1:
try:
password_length = int(wf.args[0].strip())
except ValueError:
pass
# Get args from Workflow, already in normalized Unicode
password_length = defaults['password_length']
if len(wf.args) >= 1:
try:
password_length = int(wf.args[0].strip())
except ValueError:
pass

# XKCD options
# TODO: add possibility to change options
xkcd_wordfile = defaults['xkcd_wordllist']
xkcd_min_length = defaults['xkcd_minlength']
xkcd_max_length = defaults['xkcd_maxlength']
xkcd_delimiter = defaults['xkcd_delimiter']
# XKCD options
# TODO: add possibility to change options
xkcd_wordfile = defaults['xkcd_wordllist']
xkcd_min_length = defaults['xkcd_minlength']
xkcd_max_length = defaults['xkcd_maxlength']
xkcd_delimiter = defaults['xkcd_delimiter']

# Get XKCD Wordlist and passwords
mywords = xp.generate_wordlist(wordfile=xkcd_wordfile, min_length=xkcd_min_length, max_length=xkcd_max_length)
xkcd_3 = xp.generate_xkcdpassword(mywords, 3, False, False, xkcd_delimiter)
xkcd_4 = xp.generate_xkcdpassword(mywords, 4, False, False, xkcd_delimiter)
# Get XKCD Wordlist and passwords
mywords = xp.generate_wordlist(wordfile=xkcd_wordfile,
min_length=xkcd_min_length,
max_length=xkcd_max_length)
xkcd_3 = xp.generate_xkcdpassword(mywords, 3, False, False, xkcd_delimiter)
xkcd_4 = xp.generate_xkcdpassword(mywords, 4, False, False, xkcd_delimiter)

# Allowed Special Characters
# https://www.owasp.org/index.php/Password_special_characters
special_chars = "!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"
full_pw_charset = string.ascii_uppercase + string.ascii_lowercase + string.digits + special_chars
alnum_pw_charset = string.ascii_uppercase + string.ascii_lowercase + string.digits
# Allowed Special Characters
# https://www.owasp.org/index.php/Password_special_characters
special_chars = "!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"
full_pw_charset = string.ascii_uppercase + string.ascii_lowercase + string.digits + special_chars
alnum_pw_charset = string.ascii_uppercase + string.ascii_lowercase + string.digits

# Generate passwords
full_pw = genpw(password_length, full_pw_charset)
alnum_pw = genpw(password_length, alnum_pw_charset)
# Generate passwords
full_pw = genpw(password_length, full_pw_charset)
alnum_pw = genpw(password_length, alnum_pw_charset)

# Update workflow if a new version is available.
if wf.update_available is True:
wf.add_item('New version available', 'Press enter to install the update.',
autocomplete='workflow:update',
icon=ICON_INFO
# Update workflow if a new version is available.
if wf.update_available is True:
wf.add_item('New version available', 'Press enter to install the update.',
autocomplete='workflow:update',
icon=ICON_INFO
)

# Add password items
wf.add_item('%d character password' % password_length, full_pw, valid=True, arg=full_pw)
wf.add_item('%d character password (no special characters)' % password_length, alnum_pw, valid=True, arg=alnum_pw)
wf.add_item('XKCD Password (3 words)', xkcd_3, valid=True, arg=xkcd_3)
wf.add_item('XKCD Password (4 words)', xkcd_4, valid=True, arg=xkcd_4)
# Add password items
wf.add_item('%d character password' % password_length, full_pw, valid=True, arg=full_pw)
wf.add_item('%d character password (no special characters)' % password_length, alnum_pw, valid=True, arg=alnum_pw)
wf.add_item('XKCD Password (3 words)', xkcd_3, valid=True, arg=xkcd_3)
wf.add_item('XKCD Password (4 words)', xkcd_4, valid=True, arg=xkcd_4)

# Send output to Alfred.
wf.send_feedback()
return 0
# Send output to Alfred.
wf.send_feedback()
return 0

if __name__ == '__main__':
# Create a global `Workflow` object
workflow3 = Workflow(
libraries=['./lib'], update_settings={
'github_slug': 'otherguy/alfred-passwords-workflow',
'frequency': 1, # every day
},
help_url='https://github.com/otherguy/alfred-passwords-workflow'
)
# Create a global `Workflow` object
workflow3 = Workflow(
libraries=['./lib'], update_settings={
'github_slug': 'otherguy/alfred-passwords-workflow',
'frequency': 1, # every day
},
help_url='https://github.com/otherguy/alfred-passwords-workflow'
)

workflow3.magic_prefix = 'wf:'
workflow3.magic_prefix = 'wf:'

# Call your entry function via `Workflow.run()` to enable its helper
# functions, like exception catching, ARGV normalization, magic
# arguments etc.
sys.exit(workflow3.run(main))
# Call your entry function via `Workflow.run()` to enable its helper
# functions, like exception catching, ARGV normalization, magic
# arguments etc.
sys.exit(workflow3.run(main))
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
Alfred-Workflow==1.37.2
xkcdpass==1.17.3
coverage==4.5.4
python-coveralls==2.9.3

0 comments on commit 88200c1

Please sign in to comment.