Skip to content

Instantly share code, notes, and snippets.

View adiroiban's full-sized avatar
🇺🇦
Slava Ukraini!

Adi Roiban adiroiban

🇺🇦
Slava Ukraini!
  • VGR, La Gomera
  • 07:40 (UTC +01:00)
View GitHub Profile
@adiroiban
adiroiban / child_process.py
Last active February 13, 2019 17:37
Ampoule Example from main thread
"""
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 October 31, 2018 09:36
Code to help writing tests for Twisted HTTP client
# 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
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
-----BEGIN CERTIFICATE-----
MIICTDCCAbWgAwIBAgIBATANBgkqhkiG9w0BAQUFADBGMQswCQYDVQQGEwJHQjEP
MA0GA1UEChMGQ2hldmFoMRIwEAYDVQQLEwlDaGV2YWggQ0ExEjAQBgNVBAMTCUNo
ZXZhaCBDQTAeFw0xNjA2MTAyMzA1MDBaFw0zNzA2MTAyMzA1MDBaMEYxCzAJBgNV
BAYTAkdCMQ8wDQYDVQQKEwZDaGV2YWgxEjAQBgNVBAsTCUNoZXZhaCBDQTESMBAG
A1UEAxMJQ2hldmFoIENBMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDKhnaV
43T6EcAc45RYV9/FKk3SxI4tAWw/HGpu02JLvs7BiLz4B8YUyf4IDqw/BtyLKKCx
zGw55UWIIokk5zkjp6Y9n3wmbHtJHd9Rwgm4pMibVrxjhY/Idf/3zeSakQBIrXpQ
eg53iVmn6bClaiUB1aB4wlskchmT496gZStfBQIDAQABo0owSDAMBgNVHRMEBTAD
AQH/MDgGA1UdHwQxMC8wLaAroCmGJ2h0dHA6Ly9sb2NhbGhvc3Q6ODA4MC9zb21l
@adiroiban
adiroiban / dropzone_selenium.py
Last active June 29, 2019 10:19
Script to add a file to dropzone via Selenium... from Python
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 March 24, 2018 22:56
flaky decorator
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 March 17, 2018 17:03
Statistic for pycodestyle errors in Twisted
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
"""
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 November 26, 2017 10:10
Twisted Mail SMTPConnectError strange behaviour
# 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 October 11, 2017 16:40
Urllib quote strange behaviour
(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'/')