python-2.6

Debug option for Python SFTP script like ftp_setdebug(1) to log messages

故事扮演 提交于 2019-12-11 19:04:36
问题 I am working on bash and internally calling python Script for SFTP using PYSFTP. Previously when I used FTP there was a ftp_setdebug(1) option so that I can check the Transfer and goodbye messages. But for SFTP I am not able to find any such option. I found sftp -vv but how exactly does one need to use it? Is there any other method like FTP? I don't want to include any print statements in the script. 回答1: The API of pysftp mentions that you can add a log=True to the Connection to log to a

segmentation fault for deep recursion upon going from python 2.6 to 2.7

混江龙づ霸主 提交于 2019-12-11 18:37:19
问题 I have simple recursive program to find connected subgraphs. The code works by traversing, from each unvisited vertex in the graph, all the edges (recursively) and marking those which have been visited with 'ingraph=False' in the process. (the graphs are always undirected unweighted graphs). The problem I have is that for large graphs (with a subgraph of ~100,000 vertices) python(-2.7) returns a segmentation fault. But this worked just fine in python-2.6 (and still does). Can someone explain

Fedora: NO module named RPM when using YUM

我与影子孤独终老i 提交于 2019-12-11 16:45:10
问题 I removed numpy and scipy contents from the system's Python 2.6.4 in order to install different versions for them and now I broke YUM. The error I get is the following: There was a problem importing one of the Python modules required to run yum. The error leading to this problem was: No module named rpm Please install a package which provides this module, or verify that the module is installed correctly. It's possible that the above module doesn't match the current version of Python, which is

Access Field in JSON Data

南笙酒味 提交于 2019-12-11 14:53:06
问题 I have an API response in the following JSON format. If I want to extract a field, such as geocode, how would I do so? Is it redundant to put the response in JSON? I get an error saying the list indices must be integers, not str. Thanks in advance, new to this. I've tried: import requests import json response = requests.get("https://api.weather.gov/alerts/active") data = response.json() json.loads(data['features']['id'][0]['properties'][0]['geocode'][0]) Below is JSON data: { "@context": [

exc_value parameter from __exit__() (context manager) is string instead of Exception (Python 2.6)

北城以北 提交于 2019-12-11 11:29:29
问题 I tried to mess around with context managers and got a bit surprised when running my code with Python 2.6. Indeed, the exc_value parameter seems to be a string instead of an exception. A bit of code to hi-light this issue : import sys class contextmanager(object): def __enter__(self): pass def __exit__(self, type_, value, traceback): assert (type_ is None) == (value is None) if value is not None: print(type(value)) if __name__ == '__main__': print(sys.version_info) with contextmanager(): _

Redirecting subprocess stdout

落花浮王杯 提交于 2019-12-11 10:46:17
问题 I've set up a stdout redirect using the class Redir in test.py (below). The output should show both print statements in the textbox. But currently only "Output1" is sent to the textbox and "Output2" printed in the console behind. I wondered if there was a way to redirect the stdout of a subprocess? I've tried using subprocess.PIPE and the Redir class itself but can't get it right. Note: Eventually, the Popen call won't be calling a python file, so I'm not able to just get the string from

Unable to install older wxPython within virtualenv (Cannot unpack file / Cannot determine archive format)

ⅰ亾dé卋堺 提交于 2019-12-11 10:03:24
问题 Within a virtualenv built off Python 2.6.6, I'm trying to pip install the 2.8.10.1 2.6 unicode dmg found here thus: pip install -Iv http://sourceforge.net/projects/wxpython/files/wxPython/2.8.10.1/wxPython2.8-osx-unicode-2.8.10.1-universal-py2.6.dmg/download Granted, the URL is a bit of a guess. I get (dividing the log in two): MacBook-Pro-de-Pyderman:Pyderman$ pip install -Iv http://sourceforge.net/projects/wxpython/files/wxPython/2.8.10.1/wxPython2.8-osx-unicode-2.8.10.1-universal-py2.6.dmg

python regex conditional substring extraction

隐身守侯 提交于 2019-12-11 09:36:49
问题 i am opening this question because it seems my original question requires a new direction: my original question i would like to create a regular expression that can extract STATIC MESSAGE and DYNAMIC MESSAGE from the following types of log-entries: /long/file/name/with.dots.and.extension:Jan 01 12:00:00 TYPE Static Message;Dynamic Message /long/file/name/with.dots.and.extension:Jan 01 12:00:00 MODULE.NAME TYPE THREAD.OR.CONNECTION.INFORMATION Static Message;Dynamic Message one log entry type

Outlook 2010 and Python email smtplib - info in proper fields

半腔热情 提交于 2019-12-11 09:09:37
问题 When trying to send mail through Outlook 2010 with smtplib in Python 2.6.5, I at least encounter success sending the message, but s.sendmail(FROM, TO, message) is not putting the information in the From:, To:, and Subject: lines for me. I need to know how to send email using smtplib in Outlook 2010 properly so that the email is received with the From:, To:, and Subject: fields on the message filled in. Here is my code. I googled to find this framework: import smtplib SERVER = 'mail.company

How do I create a SELECT statement with a list as a parameter?

老子叫甜甜 提交于 2019-12-11 08:19:36
问题 Code The following code only works when the list targets_in_sw only has one value in it: sw_current = cursor.execute("SELECT * from SOFTWARE_") sw_current = sw_current.fetchall() for sw_item in sw_current: current_software_id = sw_item[0] # Create Software XML Element sw_element = ET.SubElement(root, "Software") # Get all Targets for current sw_element targets_in_sw = cursor.execute("SELECT TARGET2 from SOFTWARE_TARGET_ WHERE SOFTWARE1=?", (current_software_id,)) targets_in_software = targets