Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 8, 2023
1 parent d67274b commit 753e58b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
28 changes: 17 additions & 11 deletions iembot/iembot.tac
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,42 @@
import json

from psycopg2.extras import DictCursor

# Twisted Bits
from twisted.application import service, internet
from twisted.web import server
from twisted.internet import reactor
from twisted.application import internet, service
from twisted.enterprise import adbapi
from twisted.internet import reactor
from twisted.web import server
from txyam.client import YamClient

# Local Import
from iembot import iemchatbot, webservices

with open('settings.json', encoding="utf-8") as fh:
with open("settings.json", encoding="utf-8") as fh:
dbconfig = json.load(fh)

application = service.Application("Public IEMBOT")
serviceCollection = service.IServiceCollection(application)

# This provides DictCursors!
dbrw = dbconfig.get('databaserw')
dbrw = dbconfig.get("databaserw")
dbpool = adbapi.ConnectionPool(
"psycopg2",
cp_reconnect=True,
database=dbrw.get('openfire'),
host=dbrw.get('host'),
password=dbrw.get('password'),
user=dbrw.get('user'),
database=dbrw.get("openfire"),
host=dbrw.get("host"),
password=dbrw.get("password"),
user=dbrw.get("user"),
gssencmode="disable",
cursor_factory=DictCursor,
)

memcache_client = YamClient(reactor, ['tcp:iem-memcached:11211', ])
memcache_client = YamClient(
reactor,
[
"tcp:iem-memcached:11211",
],
)
memcache_client.connect()

jabber = iemchatbot.JabberClient("iembot", dbpool, memcache_client)
Expand All @@ -41,7 +47,7 @@ defer = dbpool.runQuery("select propname, propvalue from properties")
defer.addCallback(jabber.fire_client_with_config, serviceCollection)

# 2. JSON channel requests
json = server.Site(webservices.JSONRootResource(jabber), logPath='/dev/null')
json = server.Site(webservices.JSONRootResource(jabber), logPath="/dev/null")
x = internet.TCPServer(9003, json) # pylint: disable=no-member
x.setServiceParent(serviceCollection)

Expand Down
17 changes: 10 additions & 7 deletions punjab/punjab.tac
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from twisted.python import syslog
syslog.startLogging(prefix='punjab', facility=syslog.syslog.LOG_LOCAL1)

from twisted.web import server, resource, static
from twisted.application import service, internet
syslog.startLogging(prefix="punjab", facility=syslog.syslog.LOG_LOCAL1)

from punjab.httpb import Httpb, HttpbService
from twisted.application import internet, service
from twisted.web import resource, server, static

from punjab.httpb import HttpbService

root = static.File("./html")

Expand All @@ -14,14 +15,16 @@ bosh = HttpbService(0)

# You can limit servers with a whitelist.
# The whitelist is a list of strings to match domain names.
bosh.white_list = ['weather.im', ]
bosh.white_list = [
"weather.im",
]
# or a black list
# bosh.block_list = ['jabber.org', '.thetofu.com']

root.putChild('http-bind', resource.IResource(bosh))
root.putChild("http-bind", resource.IResource(bosh))


site = server.Site(root, logPath='/dev/null')
site = server.Site(root, logPath="/dev/null")

application = service.Application("punjab")
internet.TCPServer(5280, site).setServiceParent(application)
Expand Down

0 comments on commit 753e58b

Please sign in to comment.