-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add pylint so the code has more hygeine (#34)
- Loading branch information
1 parent
9c206ea
commit 2bed0b5
Showing
6 changed files
with
144 additions
and
75 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
py36* | ||
audit.log | ||
whitelist.txt | ||
__pycache__ |
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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
language: python | ||
python: | ||
- "2.7" | ||
- "3.6" | ||
install: | ||
- pip install -r requirements-dev.txt | ||
# commands to run, must exit 0 to pass | ||
script: flake8 | ||
script: yapf --parallel --verbose --recursive --diff . | ||
script: | ||
- flake8 | ||
- yapf --parallel --verbose --recursive --diff . | ||
- pylint --max-line-length=120 *.py |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
""" | ||
All settings you can change for running slack channel reaper will live in this file. | ||
""" | ||
|
||
import os | ||
from datetime import datetime, timedelta | ||
|
||
|
||
def get_channel_reaper_settings(): | ||
""" This returns a dictionary of all settings. """ | ||
days_inactive = int(os.environ.get('DAYS_INACTIVE', 60)) | ||
return { | ||
'admin_channel': os.environ.get('ADMIN_CHANNEL', ''), | ||
'days_inactive': days_inactive, | ||
# set MIN_MEMBERS and any channels larger than this in people | ||
# are exempt from archiving. 0 is no limit. | ||
'min_members': int(os.environ.get('MIN_MEMBERS', 0)), | ||
'dry_run': (os.environ.get('DRY_RUN', 'true') == 'true'), | ||
'slack_token': os.environ.get('SLACK_TOKEN', ''), | ||
'too_old_datetime': (datetime.now() - timedelta(days=days_inactive)), | ||
'whitelist_keywords': os.environ.get('WHITELIST_KEYWORDS', ''), | ||
'skip_subtypes': {'channel_leave', 'channel_join'}, | ||
'skip_channel_str': os.environ.get('SLACK_SKIP_PURPOSE', '%noarchive'), | ||
} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
""" Helper functions that don't quite belong in the slack_autoarchive class """ | ||
|
||
import logging | ||
|
||
|
||
def get_logger(logger_name, logger_file, log_level=logging.INFO): | ||
""" Setup the logger and return it. """ | ||
log_format = '%(asctime)s - %(levelname)s - %(message)s' | ||
logging.basicConfig(level=log_level, | ||
format=log_format, | ||
datefmt='%y-%m-%d_%H:%M', | ||
filename=logger_file, | ||
filemode='w') | ||
# define a Handler which writes INFO messages or higher to the sys.stderr | ||
console = logging.StreamHandler() | ||
console.setLevel(log_level) | ||
# set a format which is simpler for console use | ||
formatter = logging.Formatter(log_format) | ||
# tell the handler to use this format | ||
console.setFormatter(formatter) | ||
# add the handler to the root logger | ||
logging.getLogger(logger_name).addHandler(console) | ||
|
||
return logging.getLogger(logger_name) |