Skip to content

Instantly share code, notes, and snippets.

View devos50's full-sized avatar

Martijn de Vos devos50

View GitHub Profile
Feb 04 15:48:46 dispersy1 python3[27508]: Traceback (most recent call last):
Feb 04 15:48:46 dispersy1 python3[27508]: File "/usr/lib/python3/dist-packages/cryptography/hazmat/backends/openssl/ec.py", line 86, in _sn_to_elliptic_curve
Feb 04 15:48:46 dispersy1 python3[27508]: return ec._CURVE_TYPES[sn]()
Feb 04 15:48:46 dispersy1 python3[27508]: KeyError: 'secp160k1'
Feb 04 15:48:46 dispersy1 python3[27508]: During handling of the above exception, another exception occurred:
Feb 04 15:48:46 dispersy1 python3[27508]: Traceback (most recent call last):
Feb 04 15:48:46 dispersy1 python3[27508]: File "scripts/tracker_plugin.py", line 64, in on_packet
Feb 04 15:48:46 dispersy1 python3[27508]: self.on_generic_introduction_request(source_address, data, data[:22])
Feb 04 15:48:46 dispersy1 python3[27508]: File "scripts/tracker_plugin.py", line 72, in on_generic_introduction_request
Feb 04 15:48:46 dispersy1 python3[27508]: auth, dist, payload = self._ez_unpack_auth(IntroductionRequestPayload, data)
@devos50
devos50 / print_extractor.py
Last active June 19, 2018 11:37
Extract all print statements from a Python project
import ast
import os
import sys
location = os.path.abspath(sys.argv[1])
exclude_from_check = ['twisted/plugins/tunnel_helper_plugin.py']
for (dirpath, dirnames, filenames) in os.walk(location):
for filename in filenames:
diff --git a/ipv8/messaging/anonymization/hidden_services.py b/ipv8/messaging/anonymization/hidden_services.py
index 3c52520..88ed2f3 100644
--- a/ipv8/messaging/anonymization/hidden_services.py
+++ b/ipv8/messaging/anonymization/hidden_services.py
@@ -23,11 +23,10 @@ TUNNEL_PREFIX = "ffffffff".decode("HEX")
class HiddenTunnelCommunity(TunnelCommunity):
def __init__(self, *args, **kwargs):
+ self.dht_provider = kwargs.pop('dht_provider', None)
+ self.service_callbacks = kwargs.pop('service_callbacks', {})
@devos50
devos50 / tribler_plugin.py
Created January 11, 2018 10:34
Twistd script
"""
This twistd plugin enables to start Tribler headless using the twistd command.
"""
from datetime import date
import os
import signal
import time
from Tribler.Core.simpledefs import NTFY_CHANNELCAST
from twisted.application.service import MultiService, IServiceMaker
set -e
shopt -s nocasematch
pids=""
for i in {1..10}; do
sleep 5 &
pids+=" $!"
done
@devos50
devos50 / app.py
Created September 7, 2017 12:46
Qt5 minimal example
import sys
import logging
import psutil
from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import QLabel
from PyQt5.QtWidgets import (QWidget, QToolTip,
QPushButton, QApplication)
from PyQt5.QtGui import QFont
iMac-van-MA:tribler martijndevos$ nosetests Tribler/Test/Core/CreditMining -v
test for add source to boosting manager ... ok
test for __bdl_callback() ... ERROR
test for checking the avtivity of a torrent ... FAIL
test for getting a credit-mining source by source key ... ok
test for storing a peer information to credit minging system ... ok
test for loading file configuration and applying it to boosting manager ... ERROR
test for log trasferring ... ok
test for inserting a torrent to boosting manager ... ok
test for renewing the value in boosting manager when having new seeder/leecher value from tracker. ... ok
@inlineCallbacks
def receive_packet(self, addresses=None, timeout=0.5):
"""
Returns the first matching (candidate, packet) tuple from incoming UDP packets.
ADDRESSES must be None or a list of address tuples. When it is a list of addresses, only
UDP packets from ADDRESSES will be returned.
"""
assert addresses is None or isinstance(addresses, list)
assert addresses is None or all(isinstance(address, tuple) for address in addresses)
class MyClass(object):
@staticmethod
def do_work():
print "doing stuff"
MyClass.do_work()
# Mock class
def other_work():
def screenshot(self):
pixmap = QPixmap(window.centralWidget().rect().size())
window.centralWidget().render(pixmap, QPoint(), QRegion(window.centralWidget().rect()))
pixmap.save(os.path.join(os.path.dirname(TriblerGUI.__file__), 'screenshots', 'screenshot_%d.jpg'
% (self.screenshots_taken + 1,)))
self.screenshots_taken += 1