Skip to content

Instantly share code, notes, and snippets.

🌴
Working from home

Adi Roiban adiroiban

View GitHub Profile
@adiroiban
adiroiban / child_process.py
Last active Feb 13, 2019
Ampoule Example from main thread
View child_process.py
"""
This code is launched in the child process.
It is also loaded/imported in the main process for AMP protocol to know the
available command, arguments and results.
Each process will use about 30MB of ram, as this is how much Twisted uses.
Having more imports here, will increase the size of the process.
"""
@adiroiban
adiroiban / testing_twisted_http_client.py
Created Oct 31, 2018
Code to help writing tests for Twisted HTTP client
View testing_twisted_http_client.py
# Copyright (c) 2014 Adi Roiban.
# See LICENSE for details.
"""
Helpers for testing code related to HTTP protocol.
"""
from __future__ import absolute_import
from httplib import HTTPConnection, HTTPSConnection
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from select import error as SelectError
View doc.diff
diff --git a/chevah/server/static/documentation/operation-client/transfers.rst b/chevah/server/static/documentation/operation-client/transfers.rst
index 5605264..0322b10 100644
--- a/chevah/server/static/documentation/operation-client/transfers.rst
+++ b/chevah/server/static/documentation/operation-client/transfers.rst
@@ -310,6 +310,10 @@ The `lowercase` is a simple transformation which will transfer the file
using destination file path and file name all in lower case.
It takes no options.
+.. note::
+ If the remote filesystem is case insensitive and a file with the same
View test
-----BEGIN CERTIFICATE-----
MIICTDCCAbWgAwIBAgIBATANBgkqhkiG9w0BAQUFADBGMQswCQYDVQQGEwJHQjEP
MA0GA1UEChMGQ2hldmFoMRIwEAYDVQQLEwlDaGV2YWggQ0ExEjAQBgNVBAMTCUNo
ZXZhaCBDQTAeFw0xNjA2MTAyMzA1MDBaFw0zNzA2MTAyMzA1MDBaMEYxCzAJBgNV
BAYTAkdCMQ8wDQYDVQQKEwZDaGV2YWgxEjAQBgNVBAsTCUNoZXZhaCBDQTESMBAG
A1UEAxMJQ2hldmFoIENBMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDKhnaV
43T6EcAc45RYV9/FKk3SxI4tAWw/HGpu02JLvs7BiLz4B8YUyf4IDqw/BtyLKKCx
zGw55UWIIokk5zkjp6Y9n3wmbHtJHd9Rwgm4pMibVrxjhY/Idf/3zeSakQBIrXpQ
eg53iVmn6bClaiUB1aB4wlskchmT496gZStfBQIDAQABo0owSDAMBgNVHRMEBTAD
AQH/MDgGA1UdHwQxMC8wLaAroCmGJ2h0dHA6Ly9sb2NhbGhvc3Q6ODA4MC9zb21l
@adiroiban
adiroiban / dropzone_selenium.py
Created Apr 17, 2018
Script to add a file to dropzone via Selenium... from Python
View dropzone_selenium.py
def addFileToDropzone(self, driver, css_selector, name, content):
"""
Trigger a file add with `name` and `content` to Dropzone element at `css_selector`.
"""
script = """
var dropzone_instance = Dropzone.forElement(css_selector)
var new_file = new File(['%s'], '%s', {type: 'application/octet-binary'})
dropzone_instance.addFile(new_file)
""" % (content, name)
driver.execute_script(script)
@adiroiban
adiroiban / flaky.py
Created Mar 24, 2018
flaky decorator
View flaky.py
def flaky(count=3, os_version=None):
"""
A decorator generator to retry a test if it fails in one of the OS from
`os_version`.
When `os_version` is None it will retry on any OS.
It will not work with any tests.
The setUp and tearDown is only called once and not called between
@adiroiban
adiroiban / pycodestyle.txt
Last active Mar 17, 2018
Statistic for pycodestyle errors in Twisted
View pycodestyle.txt
autopep8 -r -i --ignore E226,E24,W503,E3,E123,E128
-----------
1 E272 multiple spaces before keyword
2 E211 whitespace before '('
2 E743 ambiguous function definition 'l'
2 W191 indentation contains tabs
3 E101 indentation contains mixed spaces and tabs
View proxy.py
"""
Helpers for testing code related to HTTP Proxy .
It provides a context manager for starting the proxy.
Copyright (c) 2017 Adi Roiban.
License BSD
This code is based on HTTP Proxy Server in Python.
:copyright: (c) 2013 by Abhinav Singh.
@adiroiban
adiroiban / esmtp.py
Last active Nov 26, 2017
Twisted Mail SMTPConnectError strange behaviour
View esmtp.py
# Copyright (c) 2015 Adi Roiban.
# MIT License
"""
(E)SMTP high level client.
"""
from email.header import Header
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import formataddr, formatdate, make_msgid
@adiroiban
adiroiban / urllib_quote.py
Created Oct 11, 2017
Urllib quote strange behaviour
View urllib_quote.py
(Pdb) result
u'/ci-test-site/Shared Documents/v2/no such+\u2603'
(Pdb) urllib.quote(result.encode('utf-8'), safe=b'/+')
*** UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 42: ordinal not in range(128)
(Pdb) urllib.quote(result.encode('utf-8'), safe=b'+/')
'/ci-test-site/Shared%20Documents/v2/no%20such+%E2%98%83'
(Pdb) urllib.quote(result.encode('utf-8'), safe=b'/')
You can’t perform that action at this time.