Skip to content

Instantly share code, notes, and snippets.

@cas--
cas-- / gist:9026031
Created February 15, 2014 22:24
Timeit example
def func(val):
val**10
import timeit
timeit.repeat("for n in range(100): func(n)",
"from __main__ import func",
number=10000)
@cas--
cas-- / gist:9187771
Created February 24, 2014 12:48
paused announce
#!/usr/bin/env python
import libtorrent as lt
import time
import sys
import os
ses = lt.session()
ses.listen_on(6881, 6891)
info_t1 = lt.torrent_info('T1.torrent')
info_t2 = lt.torrent_info('T2.torrent')
#
# torrentmanager.py
#
# Copyright (C) 2007, 2008 Andrew Resch <[email protected]>
#
# Deluge is free software.
#
# You may redistribute it and/or modify it under the terms of the
# GNU General Public License, as published by the Free Software
# Foundation; either version 3 of the License, or (at your option)
#!/usr/bin/env python
import libtorrent as lt
import time
session = lt.session(flags=0)
print('Session started: ', lt.version)
h = session.add_torrent({'ti': lt.torrent_info('../T1.torrent'), 'save_path': './lt_test_data'})
h.auto_managed(False)
@cas--
cas-- / state_check.py
Created September 7, 2015 14:02
Verify torrents.state file
#!/usr/bin/env python
#
# Find and replace tracker urls in a Deluge torrents.state
#
# Need to edit the variables: orig_tracker_url and new_tracker_url
import os
import sys
import platform
import cPickle
@cas--
cas-- / libtorrent.modules
Last active September 16, 2015 12:21
jhbuild moduleset file for osx
<?xml version="1.0"?>
<!DOCTYPE moduleset SYSTEM "moduleset.dtd">
<?xml-stylesheet type="text/xsl" href="moduleset.xsl"?>
<moduleset>
<repository type="tarball" name="sourceforge"
href="http://downloads.sourceforge.net/sourceforge/"/>
<repository type="tarball" name="libtorrent"
href="https://github.com/arvidn/libtorrent/archive/"/>
<repository type="git" name="git.libtorrent"
href="https://github.com/arvidn/"/>
@cas--
cas-- / deb_ppa.txt
Created February 22, 2016 19:07
Debian Packaging for PPA
https://wiki.ubuntu.com/PackagingGuide/Python#The%20debhelper%20way
http://wiki.vinuxproject.org/index.php?title=Vinux_Packaging_Tutorial#3.4_Creating_New_Source
https://help.launchpad.net/Packaging/PPA
https://wiki.ubuntu.com/PbuilderHowto
http://anonscm.debian.org/gitweb/?p=collab-maint/deluge.git;a=summary
export DEBEMAIL="[email protected]"
export DEBFULLNAME="Full Name"
cd <packaging_dir>
wget http://download.deluge-torrent.org/source/deluge-<tarball version>.tar.gz
mv deluge-<tarball version>.tar.gz deluge_<tarball version>.orig.tar.gz # Use _ and add '.orig'
export DEBEMAIL="[email protected]" DEBFULLNAME="Full Name"
cd deluge_deb
git co upstream
extract tarball to deluge_deb
git add .
git ci -am "import upstream deluge <tarball version>"
deluge.tests.test_log
LogTestCase
test_twisted_error_log ... 22:01:12.170 [ERROR ][deluge.log:284 ] ('Unhandled error in Deferred:',)
22:01:12.171 [ERROR ][deluge.log:284 ] [Failure instance: Traceback (failure with no frames): <class 'deluge.component.ComponentException'>: Trying to start a component ('EventManager') not in stopped state. Current state: 'Paused'
File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1039, in _inlineCallbacks
result = g.send(result)
File "/home/ubuntu/deluge.git/deluge/tests/test_log.py", line 48, in call
yield component.start(["EventManager"])
File "/home/ubuntu/deluge.git/deluge/component.py", line 298, in start
deferreds.append(self.components[name]._component_start())
# List mounts
systemctl -t mount
# Unit starts after mount and unit is stopped when any of the mounts suddenly disappears.
After=xyz.mount
BindsTo=xyz.mount
# Also look at RequiresMountsFor