Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkowl committed Sep 13, 2018
1 parent 6c0f8d9 commit 1ef18ae
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 61 deletions.
17 changes: 12 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
steps:
- checkout
- run: docker pull matrixdotorg/sytest-synapsepy3
- run: docker run --rm -it -v $(pwd)\:/src -v $(pwd)/logs\:/logs hawkowl/sytestpy3
- run: docker run --rm -it -v $(pwd)\:/src -v $(pwd)/logs\:/logs matrixdotorg/sytest-synapsepy3
- store_artifacts:
path: ~/project/logs
destination: logs
Expand All @@ -76,7 +76,7 @@ jobs:
- checkout
- run: bash .circleci/merge_base_branch.sh
- run: docker pull matrixdotorg/sytest-synapsepy3
- run: docker run --rm -it -v $(pwd)\:/src -v $(pwd)/logs\:/logs hawkowl/sytestpy3
- run: docker run --rm -it -v $(pwd)\:/src -v $(pwd)/logs\:/logs matrixdotorg/sytest-synapsepy3
- store_artifacts:
path: ~/project/logs
destination: logs
Expand All @@ -101,6 +101,8 @@ workflows:
jobs:
- sytestpy2
- sytestpy2postgres
- sytestpy3
- sytestpy3postgres
- sytestpy2merged:
filters:
branches:
Expand All @@ -109,6 +111,11 @@ workflows:
filters:
branches:
ignore: /develop|master/
# Currently broken while the Python 3 port is incomplete
# - sytestpy3
# - sytestpy3postgres
- sytestpy3merged:
filters:
branches:
ignore: /develop|master/
- sytestpy3postgresmerged:
filters:
branches:
ignore: /develop|master/
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ matrix:
services:
- postgresql

- python: 3.5
env: TOX_ENV=py35

- python: 3.6
env: TOX_ENV=py36

Expand Down
1 change: 1 addition & 0 deletions changelog.d/3576.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Python 3.5+ is now supported.
14 changes: 10 additions & 4 deletions synapse/http/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ def get_file(self, url, output_stream, max_size=None, headers=None):

resp_headers = dict(response.headers.getAllRawHeaders())

if 'Content-Length' in resp_headers and resp_headers['Content-Length'] > max_size:
if (b'Content-Length' in resp_headers and
int(resp_headers[b'Content-Length']) > max_size):
logger.warn("Requested URL is too large > %r bytes" % (self.max_size,))
raise SynapseError(
502,
Expand Down Expand Up @@ -381,7 +382,12 @@ def get_file(self, url, output_stream, max_size=None, headers=None):
)

defer.returnValue(
(length, resp_headers, response.request.absoluteURI, response.code),
(
length,
resp_headers,
response.request.absoluteURI.decode('ascii'),
response.code,
),
)


Expand Down Expand Up @@ -466,9 +472,9 @@ def __init__(self, hs):
def endpointForURI(self, uri):
logger.info("Getting endpoint for %s", uri.toBytes())

if uri.scheme == "http":
if uri.scheme == b"http":
endpoint_factory = HostnameEndpoint
elif uri.scheme == "https":
elif uri.scheme == b"https":
tlsCreator = self.policyForHTTPS.creatorForNetloc(uri.host, uri.port)

def endpoint_factory(reactor, host, port, **kw):
Expand Down
7 changes: 6 additions & 1 deletion synapse/push/httppusher.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# limitations under the License.
import logging

import six

from prometheus_client import Counter

from twisted.internet import defer
Expand All @@ -26,6 +28,9 @@

from . import push_rule_evaluator, push_tools

if six.PY3:
long = int

logger = logging.getLogger(__name__)

http_push_processed_counter = Counter("synapse_http_httppusher_http_pushes_processed", "")
Expand Down Expand Up @@ -96,7 +101,7 @@ def on_started(self):

@defer.inlineCallbacks
def on_new_notifications(self, min_stream_ordering, max_stream_ordering):
self.max_stream_ordering = max(max_stream_ordering, self.max_stream_ordering)
self.max_stream_ordering = max(max_stream_ordering, self.max_stream_ordering or 0)
yield self._process()

@defer.inlineCallbacks
Expand Down
7 changes: 4 additions & 3 deletions synapse/push/mailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
import email.utils
import logging
import time
import urllib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

from six.moves import urllib

import bleach
import jinja2

Expand Down Expand Up @@ -474,7 +475,7 @@ def make_unsubscribe_link(self, user_id, app_id, email_address):
# XXX: make r0 once API is stable
return "%s_matrix/client/unstable/pushers/remove?%s" % (
self.hs.config.public_baseurl,
urllib.urlencode(params),
urllib.parse.urlencode(params),
)


Expand Down Expand Up @@ -561,7 +562,7 @@ def mxc_to_http_filter(value, width, height, resize_method="crop"):
return "%s_matrix/media/v1/thumbnail/%s?%s%s" % (
config.public_baseurl,
serverAndMediaId,
urllib.urlencode(params),
urllib.parse.urlencode(params),
fragment or "",
)

Expand Down
23 changes: 16 additions & 7 deletions synapse/replication/slave/storage/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import six

from synapse.storage import DataStore
from synapse.storage.end_to_end_keys import EndToEndKeyStore
from synapse.util.caches.stream_change_cache import StreamChangeCache
Expand All @@ -21,6 +23,13 @@
from ._slaved_id_tracker import SlavedIdTracker


def __func__(inp):
if six.PY3:
return inp
else:
return inp.__func__


class SlavedDeviceStore(BaseSlavedStore):
def __init__(self, db_conn, hs):
super(SlavedDeviceStore, self).__init__(db_conn, hs)
Expand All @@ -38,14 +47,14 @@ def __init__(self, db_conn, hs):
"DeviceListFederationStreamChangeCache", device_list_max,
)

get_device_stream_token = DataStore.get_device_stream_token.__func__
get_user_whose_devices_changed = DataStore.get_user_whose_devices_changed.__func__
get_devices_by_remote = DataStore.get_devices_by_remote.__func__
_get_devices_by_remote_txn = DataStore._get_devices_by_remote_txn.__func__
_get_e2e_device_keys_txn = DataStore._get_e2e_device_keys_txn.__func__
mark_as_sent_devices_by_remote = DataStore.mark_as_sent_devices_by_remote.__func__
get_device_stream_token = __func__(DataStore.get_device_stream_token)
get_user_whose_devices_changed = __func__(DataStore.get_user_whose_devices_changed)
get_devices_by_remote = __func__(DataStore.get_devices_by_remote)
_get_devices_by_remote_txn = __func__(DataStore._get_devices_by_remote_txn)
_get_e2e_device_keys_txn = __func__(DataStore._get_e2e_device_keys_txn)
mark_as_sent_devices_by_remote = __func__(DataStore.mark_as_sent_devices_by_remote)
_mark_as_sent_devices_by_remote_txn = (
DataStore._mark_as_sent_devices_by_remote_txn.__func__
__func__(DataStore._mark_as_sent_devices_by_remote_txn)
)
count_e2e_one_time_keys = EndToEndKeyStore.__dict__["count_e2e_one_time_keys"]

Expand Down
44 changes: 3 additions & 41 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -64,49 +64,11 @@ setenv =
{[base]setenv}
SYNAPSE_POSTGRES = 1

[testenv:py35]
usedevelop=true

[testenv:py36]
usedevelop=true
commands =
/usr/bin/find "{toxinidir}" -name '*.pyc' -delete
coverage run {env:COVERAGE_OPTS:} --source="{toxinidir}/synapse" \
"{envbindir}/trial" {env:TRIAL_FLAGS:} {posargs:tests/config \
tests/api/test_filtering.py \
tests/api/test_ratelimiting.py \
tests/appservice \
tests/crypto \
tests/events \
tests/handlers/test_appservice.py \
tests/handlers/test_auth.py \
tests/handlers/test_device.py \
tests/handlers/test_directory.py \
tests/handlers/test_e2e_keys.py \
tests/handlers/test_presence.py \
tests/handlers/test_profile.py \
tests/handlers/test_register.py \
tests/replication/slave/storage/test_account_data.py \
tests/replication/slave/storage/test_receipts.py \
tests/storage/test_appservice.py \
tests/storage/test_background_update.py \
tests/storage/test_base.py \
tests/storage/test__base.py \
tests/storage/test_client_ips.py \
tests/storage/test_devices.py \
tests/storage/test_end_to_end_keys.py \
tests/storage/test_event_push_actions.py \
tests/storage/test_keys.py \
tests/storage/test_presence.py \
tests/storage/test_profile.py \
tests/storage/test_registration.py \
tests/storage/test_room.py \
tests/storage/test_user_directory.py \
tests/test_distributor.py \
tests/test_dns.py \
tests/test_preview.py \
tests/test_test_utils.py \
tests/test_types.py \
tests/util} \
{env:TOXSUFFIX:}
{env:DUMP_COVERAGE_COMMAND:coverage report -m}

[testenv:packaging]
deps =
Expand Down

0 comments on commit 1ef18ae

Please sign in to comment.