Skip to content

Commit 5014a69

Browse files
authored
Merge pull request #1 from snoonetIRC/gonzobot
Just syncin' with the original
2 parents 3023f46 + f4ad903 commit 5014a69

308 files changed

Lines changed: 15983 additions & 9142 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
11
language: python
22
python:
33
- "3.4"
4+
- "3.5"
5+
- "3.6"
6+
- "3.7-dev"
7+
- "nightly"
8+
- "pypy3"
9+
10+
cache: pip
411

512
install:
613
- "sudo apt-get update -q"
7-
- "sudo apt-get install -y python3-lxml"
14+
- "sudo apt-get install -y python3-lxml libenchant-dev"
815
- "pip install -r ./travis/requirements.txt"
916

1017
script:
11-
- "python ./travis/test_json.py"
12-
- "py.test . -v --cov . --cov-report term-missing"
18+
- "py.test . -R : -v --cov . --cov-report term-missing --pylint --pylint-rcfile=travis/pylintrc"
1319

1420
after_success:
1521
- "coveralls"
16-
22+
1723
env:
1824
- PYTHONPATH=.
25+
- PYTHONPATH=. PYTHONASYNCIODEBUG=1
1926

20-
notifications:
21-
irc:
22-
channels:
23-
- "irc.esper.net#cloudbot"
24-
template:
25-
- "%{repository}#%{build_number} (%{branch} - %{commit}) %{author}: %{message} - %{build_url}"
26-
on_failure: always
27-
on_success: change
28-
skip_join: true
27+
matrix:
28+
allow_failures:
29+
- python: "3.7-dev"
30+
- python: "nightly"

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ The following guidelines for contribution should be followed if you want to subm
2222

2323
* You need a [GitHub account](https://github.com/signup/free)
2424
* Submit an [issue ticket](https://github.com/ClouDev/CloudBot/issues) for your issue if there is no one yet.
25-
* Try to describe the issue and include steps to reproduce if it's a bug.
25+
* Try to describe the issue and include steps to reproduce if it's a bug.
2626
* If you are able and want to fix this, fork the repository on GitHub
2727

2828
## Make Changes
2929

30-
* In your forked repository, create a topic branch for your upcoming patch. (optional)
30+
* In your forked repository, create a topic branch for your upcoming patch. (optional)
3131
* Make sure you stick to the coding style that is used already.
3232
* Make use of the [`.editorconfig`](http://editorconfig.org/) file.
3333
* Make commits that make sense and describe them properly.
@@ -38,7 +38,7 @@ The following guidelines for contribution should be followed if you want to subm
3838

3939
* Push your changes to a topic branch in your fork of the repository.
4040
* Open a pull request to the original repository and choose the `python3.4` branch.
41-
_Advanced users may use [`hub`](https://github.com/defunkt/hub#git-pull-request) gem for that._
41+
_Advanced users may use [`hub`](https://github.com/defunkt/hub#git-pull-request) gem for that._
4242
* If not done in commit messages (which you really should do) please reference and update your issue with the code changes. But _please do not close the issue yourself_.
4343
_Notice: You can [turn your previously filed issues into a pull-request here](http://issue2pr.herokuapp.com/)._
4444

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ CloudBot is a simple, fast, expandable open-source Python IRC Bot!
55
## Getting CloudBot
66

77
There are currently four different branches of this repository, each with a different level of stability:
8-
- **gonzobot** *(stable)*: This branch contains everything in the **master** branch plus additional plugins added for Snoonet IRC.
8+
- **gonzobot** *(stable)*: This branch contains everything in the **master** branch plus additional plugins added for Snoonet IRC. This branch is the currently maintained branch which will also contain many fixes for various bugs from the master branch.
99
- **gonzobot-dev** *(unstable)*: This branch is based off of the **gonzobot** branch and includes new plugins that are not fully tested.
10-
- **master** *(stable)*: This branch contains stable, tested code. This is the branch you should be using if you just want to run your own CloudBot! This is also the branch that EDI on Snoonet uses.
11-
- **python3.4** *(unstable)*: This branch is where where test and develop new features. If you would like to help develop CloudBot, you can use this branch.
10+
- **master** *(stable (old))*: This branch contains stable, tested code. This branch is based directly on the upstream master branch and is not currently maintained.
11+
- **python3.4** *(unstable (old))*: This is the outdated testing branch from the upstream repo.
1212

1313
New releases will be pushed from **python3.4** to **master** whenever we have a stable version to release. These changes will be merged into **gonzobot** then deployed. This should happen on a fairly regular basis, so you'll never be too far behind the latest improvements.
1414

cloudbot/__init__.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212

1313
__version__ = "1.0.9"
1414

15-
__all__ = ["util", "bot", "connection", "config", "permissions", "plugin", "event", "hook", "log_dir"]
15+
__all__ = ["clients", "util", "bot", "client", "config", "event", "hook", "permissions", "plugin", "reloader",
16+
"logging_dir"]
1617

1718

1819
def _setup():
@@ -23,6 +24,9 @@ def _setup():
2324
else:
2425
logging_config = {}
2526

27+
file_log = logging_config.get("file_log", False)
28+
console_level = "INFO" if logging_config.get("console_log_info", True) else "WARNING"
29+
2630
global logging_dir
2731
logging_dir = os.path.join(os.path.abspath(os.path.curdir), "logs")
2832

@@ -47,35 +51,41 @@ def _setup():
4751
"console": {
4852
"class": "logging.StreamHandler",
4953
"formatter": "brief",
50-
"level": "INFO",
54+
"level": console_level,
5155
"stream": "ext://sys.stdout"
52-
},
53-
"file": {
54-
"class": "logging.handlers.RotatingFileHandler",
55-
"maxBytes": 1000000,
56-
"backupCount": 5,
57-
"formatter": "full",
58-
"level": "INFO",
59-
"encoding": "utf-8",
60-
"filename": os.path.join(logging_dir, "bot.log")
6156
}
6257
},
6358
"loggers": {
6459
"cloudbot": {
6560
"level": "DEBUG",
66-
"handlers": ["console", "file"]
61+
"handlers": ["console"]
6762
}
6863
}
6964
}
7065

66+
if file_log:
67+
dict_config["handlers"]["file"] = {
68+
"class": "logging.handlers.RotatingFileHandler",
69+
"maxBytes": 1000000,
70+
"backupCount": 5,
71+
"formatter": "full",
72+
"level": "INFO",
73+
"encoding": "utf-8",
74+
"filename": os.path.join(logging_dir, "bot.log")
75+
}
76+
77+
dict_config["loggers"]["cloudbot"]["handlers"].append("file")
78+
7179
if logging_config.get("console_debug", False):
7280
dict_config["handlers"]["console"]["level"] = "DEBUG"
7381
dict_config["loggers"]["asyncio"] = {
7482
"level": "DEBUG",
75-
"handlers": ["console", "file"]
83+
"handlers": ["console"]
7684
}
85+
if file_log:
86+
dict_config["loggers"]["asyncio"]["handlers"].append("file")
7787

78-
if logging_config.get("file_debug", True):
88+
if logging_config.get("file_debug", False):
7989
dict_config["handlers"]["debug_file"] = {
8090
"class": "logging.handlers.RotatingFileHandler",
8191
"maxBytes": 1000000,
@@ -89,4 +99,5 @@ def _setup():
8999

90100
logging.config.dictConfig(dict_config)
91101

102+
92103
_setup()

cloudbot/__main__.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1-
import asyncio
21
import logging
32
import os
3+
import signal
44
import sys
55
import time
6-
import signal
6+
7+
from pathlib import Path
78

89
# store the original working directory, for use when restarting
9-
original_wd = os.path.realpath(".")
10+
original_wd = Path().resolve()
1011

1112
# set up environment - we need to make sure we are in the install directory
12-
path0 = os.path.realpath(sys.path[0] or '.')
13-
install_dir = os.path.realpath(os.path.dirname(__file__))
13+
path0 = Path(sys.path[0] or '.').resolve()
14+
install_dir = Path(__file__).resolve().parent
1415
if path0 == install_dir:
15-
sys.path[0] = path0 = os.path.dirname(install_dir)
16-
os.chdir(path0)
16+
sys.path[0] = path0 = install_dir.parent
17+
18+
os.chdir(str(install_dir.parent))
1719

1820
# import bot
1921
from cloudbot.bot import CloudBot
22+
from cloudbot.util import async_util
2023

2124

2225
def main():
@@ -40,16 +43,16 @@ def main():
4043
# define closure for signal handling
4144
# The handler is called with two arguments: the signal number and the current stack frame
4245
# These parameters should NOT be removed
46+
# noinspection PyUnusedLocal
4347
def exit_gracefully(signum, frame):
4448
nonlocal stopped_while_restarting
4549
if not _bot:
4650
# we are currently in the process of restarting
4751
stopped_while_restarting = True
4852
else:
49-
_bot.loop.call_soon_threadsafe(
50-
lambda: asyncio.async(_bot.stop("Killed (Received SIGINT {})".format(signum)), loop=_bot.loop))
53+
async_util.run_coroutine_threadsafe(_bot.stop("Killed (Received SIGINT {})".format(signum)), _bot.loop)
5154

52-
logger.warn("Bot received Signal Interrupt ({})".format(signum))
55+
logger.warning("Bot received Signal Interrupt ({})".format(signum))
5356

5457
# restore the original handler so if they do it again it triggers
5558
signal.signal(signal.SIGINT, original_sigint)
@@ -71,7 +74,7 @@ def exit_gracefully(signum, frame):
7174
logger.info("Received stop signal, no longer restarting")
7275
else:
7376
# actually restart
74-
os.chdir(original_wd)
77+
os.chdir(str(original_wd))
7578
args = sys.argv
7679
logger.info("Restarting Bot")
7780
logger.debug("Restart arguments: {}".format(args))

0 commit comments

Comments
 (0)