uWSGI backtrace error - python

I'm getting the following backtrace in my uWSGI logs, I don't know where to begin looking to figure this out:
Thu Feb 12 17:08:18 2015 - mapping worker 1 to CPUs: 0
Thu Feb 12 17:09:40 2015 - WSGI app 0 (mountpoint='') ready in 82 seconds on interpreter 0x129e3d0 pid: 21930 (default app
Thu Feb 12 17:10:11 2015 - *** HARAKIRI ON WORKER 1 (pid: 21930, try: 1) ***
Thu Feb 12 17:10:11 2015 - *** backtrace of 21930 ***
app(uwsgi_backtrace+0x2e) [0x45121e]
app(what_i_am_doing+0x30) [0x451350]
/lib/x86_64-linux-gnu/libc.so.6(+0x36d40) [0x7feea1becd40]
/lib/x86_64-linux-gnu/libc.so.6(__select+0x33) [0x7feea1ca8933]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(+0x984ed) [0x7feea092f4ed]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x4bd4) [0x7feea09f70d4]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x80d) [0x7feea09f917d]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(+0x162310) [0x7feea09f9310]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyObject_Call+0x43) [0x7feea09c0e23]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(+0x7d30d) [0x7feea091430d]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyObject_Call+0x43) [0x7feea09c0e23]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(+0x513c8) [0x7feea08e83c8]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyObject_Call+0x43) [0x7feea09c0e23]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x2316) [0x7feea09f4816]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x80d) [0x7feea09f917d]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(+0x1623e5) [0x7feea09f93e5]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyObject_Call+0x43) [0x7feea09c0e23]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0xeb1) [0x7feea09f33b1]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x80d) [0x7feea09f917d]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(+0x1623e5) [0x7feea09f93e5]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyObject_Call+0x43) [0x7feea09c0e23]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0xeb1) [0x7feea09f33b1]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x80d) [0x7feea09f917d]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(+0x162310) [0x7feea09f9310]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyObject_Call+0x43) [0x7feea09c0e23]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyObject_CallFunctionObjArgs+0x141) [0x7feea097bb61]
/var/www/app/env/local/lib/python2.7/site-packages/newrelic-2.42.0.35/newrelic/packages/wrapt/_wrappers.so(+0x416c) [0x7fee9e18516c]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyObject_Call+0x43) [0x7feea09c0e23]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0xeb1) [0x7feea09f33b1]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x80d) [0x7feea09f917d]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x48d8) [0x7feea09f6dd8]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x80d) [0x7feea09f917d]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(+0x1623e5) [0x7feea09f93e5]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyObject_Call+0x43) [0x7feea09c0e23]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0xeb1) [0x7feea09f33b1]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x80d) [0x7feea09f917d]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(+0x162310) [0x7feea09f9310]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyObject_Call+0x43) [0x7feea09c0e23]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyObject_CallFunctionObjArgs+0x141) [0x7feea097bb61]
/var/www/app/env/local/lib/python2.7/site-packages/newrelic-2.42.0.35/newrelic/packages/wrapt/_wrappers.so(+0x448a) [0x7fee9e18548a]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyObject_Call+0x43) [0x7feea09c0e23]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x2316) [0x7feea09f4816]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x80d) [0x7feea09f917d]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(+0x162310) [0x7feea09f9310]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyObject_Call+0x43) [0x7feea09c0e23]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(+0x7d30d) [0x7feea091430d]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyObject_Call+0x43) [0x7feea09c0e23]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(+0x12e5f5) [0x7feea09c55f5]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyObject_Call+0x43) [0x7feea09c0e23]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_CallObjectWithKeywords+0x47) [0x7feea097f837]
/usr/lib/uwsgi/plugins/python_plugin.so(python_call+0x11) [0x7feea0e0e4f1]
/usr/lib/uwsgi/plugins/python_plugin.so(uwsgi_request_wsgi+0x127) [0x7feea0e10847]
app(wsgi_req_recv+0xa1) [0x413f31]
app(simple_loop_run+0xc4) [0x44d5d4]
app(uwsgi_ignition+0x17b) [0x45180b]
app(uwsgi_worker_run+0x26d) [0x4523ad]
app(uwsgi_start+0x15e3) [0x453b23]
app(main+0xfb5) [0x413595]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7feea1bd7ec5]
app() [0x413649]
*** end of backtrace ***
Thu Feb 12 17:10:11 2015 - HARAKIRI: --- uWSGI worker 1 (pid: 21930) WAS managing request /v3/remoco/now_next since Thu Feb 12 17:09:40 2015 ---
Thu Feb 12 17:10:13 2015 - *** HARAKIRI ON WORKER 1 (pid: 21930, try: 2) ***
Thu Feb 12 17:10:14 2015 - DAMN ! worker 1 (pid: 21930) died, killed by signal 9 :( trying respawn ...
Thu Feb 12 17:10:14 2015 - Respawned uWSGI worker 1 (new pid: 21985)
Thu Feb 12 17:10:14 2015 - mapping worker 1 to CPUs: 0
I thought maybe the newrelic lines might have something to do with it so I disabled newrelic on the machines but I get the same backtrace without the newrelic lines.
I'm running uWSGI version 1.9.17.1-debian on Ubuntu 14.04 and all updates have been applied.
This is my uWSGI app config:
[uwsgi]
; define variables to use in this script
; process name for easy identification in top
project = app
base_dir = /var/www/%(project)
chdir = %(base_dir)
plugins = python
virtualenv = %(base_dir)/env
uid = www-data
gid = www-data
procname = %(project)
; This value needs to be tuned
workers = 12
max-request = 40000
harakiri = 30
reload-mercy = 8
cpu-affinity = 2
reload-on-as = 512
reload-on-rss = 192
no-orphans = true
master = true
; Create pid file for easier process management
pidfile2 = %(base_dir)/run/%(project).pid
; Specify your app here
wsgi-file = %(base_dir)/project/%(project)-wsgi.py
log-reopen = true
logto2 = %(base_dir)/logs/uwsgi.log
chmod-socket = 666
vacuum = true
enable-threads = true
single-interpreter = true
lazy-apps = true
buffer-size=32768
; unix socket
socket = /tmp/%(project)-server.sock
; Enable stats
stats = /tmp/%(project)-stats.sock
Let me know if there is anything else I can add to this and I will.

Related

Error reading point values from bacnet device

import BAC0
bacnet = BAC0.connect()
my_obj_list = [('file', 1),
('analogInput', 1002),
('analogInput', 1),
('analogInput', 1006),
('analogInput', 1011),
('analogInput', 1010),
('analogInput', 1001)]
# # Provide it as an argument
fx = BAC0.device('16102:19', 1610219, bacnet, object_list = my_obj_list)
p=fx.points
for point in p:
print(point)
The code is returning the point values as expected, but throwing an exception. Can not figure out what I'm doing wrong.
error
2018-11-26 17:45:51,864 - INFO | Starting BAC0 version 0.99.944 (Lite)
2018-11-26 17:45:51,908 - INFO | Using ip : 192.168.0.16
2018-11-26 17:45:51,909 - INFO | Starting app...
2018-11-26 17:45:51,910 - INFO | BAC0 started
2018-11-26 17:45:51,910 - INFO | Registered as Simple BACnet/IP App
2018-11-26 17:45:54,529 - INFO | Changing device state to DeviceDisconnected'>
2018-11-26 17:45:54,726 - INFO | Changing device state to RPDeviceConnected'>
2018-11-26 17:45:54,928 - INFO | Device 1610219:[device1610219] found... building points list
2018-11-26 17:45:57,674 - INFO | Ready!
2018-11-26 17:45:57,676 - INFO | Polling started, values read every 10 seconds
Exception in thread rpm_poll:
Traceback (most recent call last):
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:_website\BacTest\venv\lib\site-packages\BAC0\tasks\TaskManager.py", line 45, in run
self.process()
File "C:_website\BacTest\venv\lib\site-packages\BAC0\tasks\TaskManager.py", line 52, in process
self.task()
File "C:_website\BacTest\venv\lib\site-packages\BAC0\tasks\Poll.py", line 77, in task
self.device.read_multiple(list(self.device.points_name), points_per_request=25)
File "C:_website\BacTest\venv\lib\site-packages\BAC0\core\devices\mixins\read_mixin.py", line 452, in read_multiple
self.read_single(each,points_per_request=1, discover_request=discover_request)
File "C:_website\BacTest\venv\lib\site-packages\BAC0\core\devices\mixins\read_mixin.py", line 459, in read_single
return self.properties.network.read(request)
File "C:_website\BacTest\venv\lib\site-packages\BAC0\core\io\Read.py", line 87, in read
args_split, arr_index=arr_index, vendor_id=vendor_id, bacoid=bacoid))
File "C:_website\BacTest\venv\lib\site-packages\BAC0\core\io\Read.py", line 310, in build_rp_request
addr, obj_type, obj_inst, prop_id = args[:4]
ValueError: not enough values to unpack (expected 4, got 2)
device1610219/ai_2 : 2.30 noUnits
device1610219/zone_temp : 45.00 degreesFahrenheit
device1610219/ai_6 : 75.00 degreesFahrenheit
device1610219/ai_11 : 1.00 65535
device1610219/ai_10 : -53.30 degreesFahrenheit
device1610219/ai_1 : 0.00 noUnits
Process finished with exit code 0
I've made some tests trying to replicate your bug and I think you may be fighting with a weird device.
Using the exact same script I succeed reading all points.
If I may suggest though, declaring your device using default "poll" parameters will assure reading of all points every 10 seconds.
Using points will force a reading of points (one by one) when called which will slow the process. For that, I would use point.lastValue
When the device polls its point list, internally, it'll use a ReadPropertyMultiple that will read a bunch of points and properties at the same time. It is more efficient.
Something like (playing with format...) :
import BAC0
bacnet = BAC0.lite()
# # Provide it as an argument
fx = BAC0.device('2:5', 5, bacnet)
for name in fx.points_name:
if fx[name].units:
val = '{:>10.2f}'.format(fx[name].lastValue)
units = fx[name].units
else:
units = '({})'.format(fx[name].properties.units_state)
val = '{:>10}'.format(fx[name].lastValue)
print('{:<20} : {} {:<10}'.format(fx[name].properties.name, val, units))
(Extract of result)
2018-12-06 20:43:17,167 - INFO | Starting BAC0 version 0.99.944 (Lite)
2018-12-06 20:43:17,283 - INFO | Using ip : 192.168.210.11
2018-12-06 20:43:17,285 - INFO | Starting app...
2018-12-06 20:43:17,292 - INFO | BAC0 started
2018-12-06 20:43:17,292 - INFO | Registered as Simple BACnet/IP App
2018-12-06 20:43:19,295 - INFO | Changing device state to DeviceDisconnected'>
2018-12-06 20:43:20,156 - INFO | Changing device state to RPMDeviceConnected'>
2018-12-06 20:43:20,716 - INFO | Device 5:[FX14 0005] found... building points
2018-12-06 20:43:32,691 - INFO | Ready!
2018-12-06 20:43:32,696 - INFO | Polling started, values read every 10 seconds
nvoAI3 : -1.17 degreesCelsius
nvoAI4 : 42.33 percent
nvoAI6 : 354.00 kilopascals
nvoAI5 : 1.85 percent
nvoAI1 : 22.05 degreesCelsius
nvoAI2 : 20.84 degreesCelsius
[...]
nciOvrdDO5.State : 1 (['AUTO', 'ON', 'OFF'])
nvoAlarmPompe : 1 (['OFF', 'ON'])
nvoAlrmGravePompe : 1 (['OFF', 'ON'])
nvoTempOccup : 1 (['OFF', 'ON'])
nciModeOperation : 2 (['ARRET', 'AUTO', 'CHAUFF', 'REFROID', 'ELECTR'])
nciOvrdDO2.State : 1 (['AUTO', 'ON', 'OFF'])
nciOvrdDO3.State : 1 (['AUTO', 'ON', 'OFF'])
nciOvrdDO4.State : 1 (['AUTO', 'ON', 'OFF'])
nciOvrdDO1.State : 1 (['AUTO', 'ON', 'OFF'])
nciModeDeshum : 1 (['Aucune', 'Ventilation', 'Rechauff'])
nciOvrdAO1.State : 2 (['AUTO', 'MAN', '100', '0'])
nciOvrdAO2.State : 1 (['AUTO', 'MAN', '100', '0'])
nvoDI7 : inactive (('Off', 'On'))
nvoDI8 : inactive (('Off', 'On'))
nvoDI10 : inactive (('Off', 'On'))
nvoDI9 : inactive (('Off', 'On'))
nvoDI6 : inactive (('Off', 'On'))
nvoDI4 : inactive (('Off', 'On'))
If you keep getting issues, please post one here : https://github.com/ChristianTremblay/BAC0/issues

for x in y loop capture instance value

If I have a string like the following:
output = '''
Certificate 1:
Valid from: Mon Jun 12 14:58:50 EDT 2017
Valid until: Wed Jun 12 15:28:50 EDT 2019
Certificate 2:
Valid from: Mon Jun 12 15:00:43 EDT 2017
Valid until: Wed Jun 12 15:30:43 EDT 2019
'''
I want to differentiate between the two values when I convert to unixtime. How do I tell it when it's Certificate 1 or Certificate 2?
This is what I have so far, works for getting the two dates, but I don't know how to say if it's the first result then it's Certificate 1.
for line in output.splitlines():
if 'Valid until' in line:
environment = '???'
valid_until_time = (line.split(':', 1)[1]).strip()[4:]
valid_until_time = valid_until_time.replace(' EDT', '')
unixtime = time.mktime(datetime.strptime(valid_until_time, '%b %d %H:%M:%S %Y').timetuple())
send_to_zabbixsender(zabbix_executable,
zabbix_config,
item_key='{0}.expirydate'.format(environment),
item_value=unixtime)
just store current certificate as a state when you encounter it:
import time
from datetime import datetime
output = '''
Certificate 1:
Valid from: Mon Jun 12 14:58:50 EDT 2017
Valid until: Wed Jun 12 15:28:50 EDT 2019
Certificate 2:
Valid from: Mon Jun 12 15:00:43 EDT 2017
Valid until: Wed Jun 12 15:30:43 EDT 2019
'''
current_certificate = 0
for line in output.splitlines():
if line.startswith("Certificate"):
current_certificate = int(line.split()[1].rstrip(":"))
if 'Valid until' in line:
environment = '???'
valid_until_time = (line.split(':', 1)[1]).strip()[4:]
valid_until_time = valid_until_time.replace(' EDT', '')
unixtime = time.mktime(datetime.strptime(valid_until_time, '%b %d %H:%M:%S %Y').timetuple())
print("{}: {}".format(current_certificate,unixtime))
this standalone example prints:
1: 1560346130.0
2: 1560346243.0
there's lots of different ways to solve this problem.
One way is by simply checking if it's cert 1 or 2
for line in output.splitlines():
if 'Certificate 1' in line: cert1Bool = True
if 'Certificate 2' in line: cert1Bool = False
Then move forward with the rest of your code, only check cert1Bool as needed
I would just keep track of current certificate outside of the for loop.
e.g.:
certificate = ''
for line in output.splitlines():
if 'certificate' in line:
certificate = line
else if 'Valid until' in line:
environment = certificate
valid_until_time = (line.split(':', 1)[1]).strip()[4:]
valid_until_time = valid_until_time.replace(' EDT', '')
unixtime = time.mktime(datetime.strptime(valid_until_time, '%b %d %H:%M:%S %Y').timetuple())
send_to_zabbixsender(zabbix_executable,
zabbix_config,
item_key='{0}.expirydate'.format(environment),
item_value=unixtime)

Exception/Error Handling in Python

I have a class that I created, at the end of the task I have to create two lists: one for tweets and the other for tweet labels.
After initiation, I want to load the tweets from a file and from another file their labels. After loading I want to check that each tweet is a json object and that it has no error, if it does, then I want to remove it and remove the associated label if provided. Labels are either 'pos' or 'neg'.
class flu_tweets:
def __init__(self):
self.tweets = [] #init create empty tweet list
self.labels = [] #init create empty label list
def load(self, tweets_filename, labels_filename = ''):
open_tweet_file = open(tweets_filename, 'r')
for tweet in open_tweet_file:
if tweet !='\n' and tweet != '\r\n':
self.tweets.extend([tweet])
if labels_filename != '':
open_label_file = open(labels_filename, 'r')
for label in open_label_file:
if label != '\n' and label != '\r\n':
if label[3:] != '\n':
self.labels.extend([label[:3]])
else:
self.labels.extend([label])
open_label_file.close()
index_tweet = 0
for tweet in self.tweets:
try:
json.loads(tweet)
index_tweet += 1
break
except:
print(index_tweet-1)
self.tweets.pop(index_tweet-1)
if self.labels != []:
self.labels.pop(index_tweet-1)
open_tweet_file.close()
Right now the method doesn't do that, and upon checking the list it does contain non-json objects.
Below is a copy of text file used that has tweets in it:
{"created_at":"Fri Oct 20 14:35:19 +0000 2017","id":921384339421745153,"id_str":"921384339421745153","text":"RT #alvindchipmunk: Dont let the DNC slide with no handcuffs. https://t.co/h72q7lGAHF","source":"\u003ca href=\"http://twitter.com/download/iphone\" rel=\"nofollow\"\u003eTwitter for iPhone\u003c/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":3435638633,"id_str":"3435638633","name":"alwaystrump","screen_name":"rodilosso_patty","location":"New Jersey, USA","url":null,"description":"Let's not give the media the Race war they want. POTUS we have your back! MAGA","translator_type":"none","protected":false,"verified":false,"followers_count":2770,"friends_count":2048,"listed_count":183,"favourites_count":85745,"statuses_count":152520,"created_at":"Sat Aug 22 16:27:18 +0000 2015","utc_offset":null,"time_zone":null,"geo_enabled":true,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"C0DEED","profile_background_image_url":"http://abs.twimg.com/images/themes/theme1/bg.png","profile_background_image_url_https":"https://abs.twimg.com/images/themes/theme1/bg.png","profile_background_tile":false,"profile_link_color":"1DA1F2","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"profile_image_url":"http://pbs.twimg.com/profile_images/773719268026257410/AuXU_l-D_normal.jpg","profile_image_url_https":"https://pbs.twimg.com/profile_images/773719268026257410/AuXU_l-D_normal.jpg","profile_banner_url":"https://pbs.twimg.com/profile_banners/3435638633/1461499638","default_profile":true,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"retweeted_status":{"created_at":"Fri Oct 20 12:27:04 +0000 2017","id":921352064160034816,"id_str":"921352064160034816","text":"Dont let the DNC slide with no handcuffs. https://t.co/h72q7lGAHF","display_text_range":[0,41],"source":"\u003ca href=\"http://twitter.com\" rel=\"nofollow\"\u003eTwitter Web Client\u003c/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":35962023,"id_str":"35962023","name":"alvin maldonado","screen_name":"alvindchipmunk","location":"Bunnell, FL","url":"http://alvindchipmunk-theconservativecomet.blogspot.com/","description":"Artist-musician-Medical Professional-Patriot-Guns-God-Country & 2Unite with others of like mind 2 re-elect Trump, redecorate DC making d USA gr8 as it still is","translator_type":"none","protected":false,"verified":false,"followers_count":1660,"friends_count":2051,"listed_count":43,"favourites_count":2001,"statuses_count":16294,"created_at":"Tue Apr 28 02:43:18 +0000 2009","utc_offset":-14400,"time_zone":"Eastern Time (US & Canada)","geo_enabled":true,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"9818A1","profile_background_image_url":"http://pbs.twimg.com/profile_background_images/627772771741732864/MHLgViA4.jpg","profile_background_image_url_https":"https://pbs.twimg.com/profile_background_images/627772771741732864/MHLgViA4.jpg","profile_background_tile":true,"profile_link_color":"981CEB","profile_sidebar_border_color":"DE3C88","profile_sidebar_fill_color":"E887E8","profile_text_color":"333333","profile_use_background_image":true,"profile_image_url":"http://pbs.twimg.com/profile_images/542852260422639616/75bqMWY3_normal.jpeg","profile_image_url_https":"https://pbs.twimg.com/profile_images/542852260422639616/75bqMWY3_normal.jpeg","profile_banner_url":"https://pbs.twimg.com/profile_banners/35962023/1481464103","default_profile":false,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"quoted_status_id":920847040132792320,"quoted_status_id_str":"920847040132792320","quoted_status":{"created_at":"Thu Oct 19 03:00:17 +0000 2017","id":920847040132792320,"id_str":"920847040132792320","text":"I'm sick of all the evidence against the Democrats and no handcuffs. Retweet-\nif you agree!\n\n#realDonaldTrump \ud83c\uddfa\ud83c\uddf8","source":"\u003ca href=\"http://twitter.com/download/android\" rel=\"nofollow\"\u003eTwitter for Android\u003c/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":889982846428782592,"id_str":"889982846428782592","name":"c\u2113\u03b9\u03b7\u0442\u03c3\u03b7 \u043c\u03b9c\u043d\u03b1\u03b5\u2113","screen_name":"crusher614","location":"*not of this world","url":"https://www.youtube.com/channel/UCthNh_qChVqAh_zamo0IQxQ","description":"FMR U.S. Border Patrol | New Mexico SWAT Operator | Legend Who Lives Rent Free In The Minds of Liberals World Wide. #MAGA \u03bc\u03bf\u03bb\u1f7c\u03bd \u03bb\u03b1\u03b2\u03ad III","translator_type":"none","protected":false,"verified":false,"followers_count":19821,"friends_count":135,"listed_count":73,"favourites_count":16032,"statuses_count":7708,"created_at":"Tue Jul 25 22:57:00 +0000 2017","utc_offset":-25200,"time_zone":"America/Phoenix","geo_enabled":false,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"000000","profile_background_image_url":"http://abs.twimg.com/images/themes/theme1/bg.png","profile_background_image_url_https":"https://abs.twimg.com/images/themes/theme1/bg.png","profile_background_tile":false,"profile_link_color":"19CF86","profile_sidebar_border_color":"000000","profile_sidebar_fill_color":"000000","profile_text_color":"000000","profile_use_background_image":false,"profile_image_url":"http://pbs.twimg.com/profile_images/916414292882219008/fvSIJCC6_normal.jpg","profile_image_url_https":"https://pbs.twimg.com/profile_images/916414292882219008/fvSIJCC6_normal.jpg","profile_banner_url":"https://pbs.twimg.com/profile_banners/889982846428782592/1506312325","default_profile":false,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"quote_count":551,"reply_count":703,"retweet_count":15439,"favorite_count":13676,"entities":{"hashtags":[],"urls":[],"user_mentions":[{"screen_name":"realDonaldTrump","name":"Donald J. Trump","id":25073877,"id_str":"25073877","indices":[93,109]}],"symbols":[]},"favorited":false,"retweeted":false,"filter_level":"low","lang":"en"},"is_quote_status":true,"quote_count":0,"reply_count":0,"retweet_count":1,"favorite_count":0,"entities":{"hashtags":[],"urls":[{"url":"https://t.co/h72q7lGAHF","expanded_url":"https://twitter.com/crusher614/status/920847040132792320","display_url":"twitter.com/crusher614/sta\u2026","indices":[42,65]}],"user_mentions":[],"symbols":[]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"filter_level":"low","lang":"en"},"quoted_status_id":920847040132792320,"quoted_status_id_str":"920847040132792320","quoted_status":{"created_at":"Thu Oct 19 03:00:17 +0000 2017","id":920847040132792320,"id_str":"920847040132792320","text":"I'm sick of all the evidence against the Democrats and no handcuffs. Retweet-\nif you agree!\n\n#realDonaldTrump \ud83c\uddfa\ud83c\uddf8","source":"\u003ca href=\"http://twitter.com/download/android\" rel=\"nofollow\"\u003eTwitter for Android\u003c/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":889982846428782592,"id_str":"889982846428782592","name":"c\u2113\u03b9\u03b7\u0442\u03c3\u03b7 \u043c\u03b9c\u043d\u03b1\u03b5\u2113","screen_name":"crusher614","location":"*not of this world","url":"https://www.youtube.com/channel/UCthNh_qChVqAh_zamo0IQxQ","description":"FMR U.S. Border Patrol | New Mexico SWAT Operator | Legend Who Lives Rent Free In The Minds of Liberals World Wide. #MAGA \u03bc\u03bf\u03bb\u1f7c\u03bd \u03bb\u03b1\u03b2\u03ad III","translator_type":"none","protected":false,"verified":false,"followers_count":19821,"friends_count":135,"listed_count":73,"favourites_count":16032,"statuses_count":7708,"created_at":"Tue Jul 25 22:57:00 +0000 2017","utc_offset":-25200,"time_zone":"America/Phoenix","geo_enabled":false,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"000000","profile_background_image_url":"http://abs.twimg.com/images/themes/theme1/bg.png","profile_background_image_url_https":"https://abs.twimg.com/images/themes/theme1/bg.png","profile_background_tile":false,"profile_link_color":"19CF86","profile_sidebar_border_color":"000000","profile_sidebar_fill_color":"000000","profile_text_color":"000000","profile_use_background_image":false,"profile_image_url":"http://pbs.twimg.com/profile_images/916414292882219008/fvSIJCC6_normal.jpg","profile_image_url_https":"https://pbs.twimg.com/profile_images/916414292882219008/fvSIJCC6_normal.jpg","profile_banner_url":"https://pbs.twimg.com/profile_banners/889982846428782592/1506312325","default_profile":false,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"quote_count":551,"reply_count":703,"retweet_count":15439,"favorite_count":13676,"entities":{"hashtags":[],"urls":[],"user_mentions":[{"screen_name":"realDonaldTrump","name":"Donald J. Trump","id":25073877,"id_str":"25073877","indices":[93,109]}],"symbols":[]},"favorited":false,"retweeted":false,"filter_level":"low","lang":"en"},"is_quote_status":true,"quote_count":0,"reply_count":0,"retweet_count":0,"favorite_count":0,"entities":{"hashtags":[],"urls":[{"url":"https://t.co/h72q7lGAHF","expanded_url":"https://twitter.com/crusher614/status/920847040132792320","display_url":"twitter.com/crusher614/sta\u2026","indices":[62,85]}],"user_mentions":[{"screen_name":"alvindchipmunk","name":"alvin maldonado","id":35962023,"id_str":"35962023","indices":[3,18]}],"symbols":[]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"filter_level":"low","lang":"en","timestamp_ms":"1508510119668"}
{"created_at":"Fri Oct 20 14:35:19 +0000 2017","id":921384340113670149,"id_str":"921384340113670149","text":"RT #mitchelmusso: My girl is so fine! but gaw}
Now that last tweet is incomplete,I expect that my function should raise an error and eliminate it.

How do I convert a yaml block to a json block with python?

I have this script that generates yaml data. I need it to produce the equivalent json data.
The code is this:
def main(argv):
global top
global version
global package
librivox_rest_url = 'unknown'
app_image_url = 'unknown'
password = 'XXXXXXX'
try:
opts, args = getopt.getopt(argv,"hl:t:v:k:p:i:",["url=","top=","version=","package=","password=","image_url="])
except getopt.GetoptError:
print 'make_hiera_data_from_librivox_api.py -l <librvox url> [-t <top>] [-v <version>] [-p <password>]'
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
usage ( 'Help called' )
sys.exit(0)
elif opt in ("-l", "--url"):
librivox_rest_url = arg
elif opt in ("-t", "--top"):
top = arg
elif opt in ("-v", "--version"):
version = arg
elif opt in ("-p", "--password"):
password = arg
elif opt in ("-k", "--package"):
password = arg
elif opt in ("-i", "--image_url"):
app_image_url = arg
if ( librivox_rest_url == 'unknown' ):
usage ("Please specify a librivox api url")
sys.exit (1)
if ( app_image_url == 'unknown' ):
usage ("Please specify the app image url")
sys.exit (1)
parsed = json.loads(requests.get(librivox_rest_url).text)
book_key = parsed['books'].keys()[0]
apptitle = parsed['books'][book_key]['title']
app_image_url = app_image_url
app_zip_url = parsed['books'][book_key]['url_zip_file']
description = parsed['books'][book_key]['description']
yaml_version = """---
top: '%s'
package: '%s'
version: %s
password: '%s'
make_audiobook::package_name: "%%{hiera('package')}"
make_audiobook::description::description: %s
make_audiobook::version: "%%{hiera('version')}"
make_audiobook::mp3filesdir: "%%{hiera('top')}/%%{::appname}/%%{::appname}/res/raw"
make_audiobook::app_image::app_image_url: '%s'
make_audiobook::app_image::resource_path: "%%{hiera('top')}/%%{::appname}/%%{::appname}"
make_audiobook::app_image::appdir: "%%{hiera('top')}/%%{::appname}"
make_audiobook::app_image::appname: "%%{::appname}"
make_audiobook::app_javacode::appname: "%%{::appname}"
make_audiobook::app_javacode::password: "%%{hiera('password')}"
make_audiobook::app_javacode::apptitle: "%s"
make_audiobook::app_javacode::package: "%%{hiera('package')}"
make_audiobook::app_javacode::path_to_code: "%%{hiera('top')}/%%{::appname}/%%{::appname}/src/com/%%{hiera('package')}/%%{::appname}"
make_audiobook::app_javacode::path_to_androidmanifest: "%%{hiera('top')}/%%{::appname}/%%{::appname}"
make_audiobook::app_javacode::version: "%%{hiera('version')}"
make_audiobook::app_javacode::tracks: """ % (top, package, version, password, description.encode('ascii', 'ignore').decode('ascii'), app_image_url, apptitle)
for thing in get_filenames_from_zip_file (app_zip_url):
if ( thing ):
yaml_version += " - %s\n" % thing
print '''
make_audiobook::app_javacode::track_titles:
'''.strip()
for thing in parsed['books'][book_key]['sections']:
yaml_version += " - %s\n" % (thing['title'])
yaml_version += """
make_audiobook::create_project::workspace: "%%{hiera('top')}/%%{::appname}"
make_audiobook::create_project::appname: "%%{::appname}"
make_audiobook::create_project::package_name: "%%{hiera('package')}"
make_audiobook::create_project::android: '/home/plankton/android-sdk-linux/tools/android'
make_audiobook::generate_keystore::top: "%%{hiera('top')}"
make_audiobook::generate_keystore::password: "%%{hiera('password')}"
make_audiobook::ant_debug::workspace: "%%{hiera('top')}/%%{::appname}"
make_audiobook::app_mp3files::app_zip_url: '%s'
make_audiobook::app_mp3files::resource_path: "%%{hiera('top')}/%%{::appname}/%%{::appname}"
make_audiobook::app_drawables::path_to_drawables: "%%{hiera('top')}/%%{::appname}/%%{::appname}/res/drawable-hdpi"
""" % (app_zip_url)
print yaml_version
print json.dumps( yaml_version, sort_keys=True, indent=2)
When I run the script I get this output where the json data is just one big long line. What am I doing wrong?
make_audiobook::app_javacode::track_titles:
---
top: '/home/get_links/TEMPLATE_FILES'
package: 'redcricket'
version: 1
password: 'XXXXXXX'
make_audiobook::package_name: "%{hiera('package')}"
make_audiobook::description::description: <p>"The Art of War is a Chinese military treatise written during the 6th century BC by Sun Tzu. Composed of 13 chapters, each of which is devoted to one aspect of warfare, it has long been praised as the definitive work on military strategies and tactics of its time. The Art of War is one of the oldest and most famous studies of strategy and has had a huge influence on both military planning and beyond. The Art of War has also been applied, with much success, to business and managerial strategies." (summary from Wikipedia)</p>
make_audiobook::version: "%{hiera('version')}"
make_audiobook::mp3filesdir: "%{hiera('top')}/%{::appname}/%{::appname}/res/raw"
make_audiobook::app_image::app_image_url: 'https://ia801509.us.archive.org/7/items/song_of_the_wave_1703_librivox/songwave_1703.jpg'
make_audiobook::app_image::resource_path: "%{hiera('top')}/%{::appname}/%{::appname}"
make_audiobook::app_image::appdir: "%{hiera('top')}/%{::appname}"
make_audiobook::app_image::appname: "%{::appname}"
make_audiobook::app_javacode::appname: "%{::appname}"
make_audiobook::app_javacode::password: "%{hiera('password')}"
make_audiobook::app_javacode::apptitle: "Art of War"
make_audiobook::app_javacode::package: "%{hiera('package')}"
make_audiobook::app_javacode::path_to_code: "%{hiera('top')}/%{::appname}/%{::appname}/src/com/%{hiera('package')}/%{::appname}"
make_audiobook::app_javacode::path_to_androidmanifest: "%{hiera('top')}/%{::appname}/%{::appname}"
make_audiobook::app_javacode::version: "%{hiera('version')}"
make_audiobook::app_javacode::tracks: - art_of_war_01-02_sun_tzu_64kb
- art_of_war_03-04_sun_tzu_64kb
- art_of_war_05-06_sun_tzu_64kb
- art_of_war_07-08_sun_tzu_64kb
- art_of_war_09-10_sun_tzu_64kb
- art_of_war_11_sun_tzu_64kb
- art_of_war_12-13_sun_tzu_64kb
- 01 - Laying Plans / 02 - Waging War
- 03 - Attack By Stratagem / 04 - Tactical Dispositions
- 05 - Energy / 06 - Weak Points and Strong
- 07 - Maneuvering / 08 - Variation in Tactics
- 09 - The Army on the March / 10 - Terrain
- 11 - The Nine Situations
- 12 - The Attack By Fire / 13 - The Use of Spies
make_audiobook::create_project::workspace: "%{hiera('top')}/%{::appname}"
make_audiobook::create_project::appname: "%{::appname}"
make_audiobook::create_project::package_name: "%{hiera('package')}"
make_audiobook::create_project::android: '/home/plankton/android-sdk-linux/tools/android'
make_audiobook::generate_keystore::top: "%{hiera('top')}"
make_audiobook::generate_keystore::password: "%{hiera('password')}"
make_audiobook::ant_debug::workspace: "%{hiera('top')}/%{::appname}"
make_audiobook::app_mp3files::app_zip_url: 'http://www.archive.org/download/art_of_war_librivox/art_of_war_librivox_64kb_mp3.zip'
make_audiobook::app_mp3files::resource_path: "%{hiera('top')}/%{::appname}/%{::appname}"
make_audiobook::app_drawables::path_to_drawables: "%{hiera('top')}/%{::appname}/%{::appname}/res/drawable-hdpi"
"---\ntop: '/home/get_links/TEMPLATE_FILES'\npackage: 'redcricket'\nversion: 1\npassword: 'XXXXXXX'\nmake_audiobook::package_name: \"%{hiera('package')}\"\nmake_audiobook::description::description: <p>\"The Art of War is a Chinese military treatise written during the 6th century BC by Sun Tzu. Composed of 13 chapters, each of which is devoted to one aspect of warfare, it has long been praised as the definitive work on military strategies and tactics of its time. The Art of War is one of the oldest and most famous studies of strategy and has had a huge influence on both military planning and beyond. The Art of War has also been applied, with much success, to business and managerial strategies.\" (summary from Wikipedia)</p>\n\nmake_audiobook::version: \"%{hiera('version')}\"\nmake_audiobook::mp3filesdir: \"%{hiera('top')}/%{::appname}/%{::appname}/res/raw\"\nmake_audiobook::app_image::app_image_url: 'https://ia801509.us.archive.org/7/items/song_of_the_wave_1703_librivox/songwave_1703.jpg'\nmake_audiobook::app_image::resource_path: \"%{hiera('top')}/%{::appname}/%{::appname}\"\nmake_audiobook::app_image::appdir: \"%{hiera('top')}/%{::appname}\"\nmake_audiobook::app_image::appname: \"%{::appname}\"\nmake_audiobook::app_javacode::appname: \"%{::appname}\"\nmake_audiobook::app_javacode::password: \"%{hiera('password')}\"\nmake_audiobook::app_javacode::apptitle: \"Art of War\"\nmake_audiobook::app_javacode::package: \"%{hiera('package')}\"\nmake_audiobook::app_javacode::path_to_code: \"%{hiera('top')}/%{::appname}/%{::appname}/src/com/%{hiera('package')}/%{::appname}\"\nmake_audiobook::app_javacode::path_to_androidmanifest: \"%{hiera('top')}/%{::appname}/%{::appname}\"\nmake_audiobook::app_javacode::version: \"%{hiera('version')}\"\nmake_audiobook::app_javacode::tracks: - art_of_war_01-02_sun_tzu_64kb\n - art_of_war_03-04_sun_tzu_64kb\n - art_of_war_05-06_sun_tzu_64kb\n - art_of_war_07-08_sun_tzu_64kb\n - art_of_war_09-10_sun_tzu_64kb\n - art_of_war_11_sun_tzu_64kb\n - art_of_war_12-13_sun_tzu_64kb\n - 01 - Laying Plans / 02 - Waging War\n - 03 - Attack By Stratagem / 04 - Tactical Dispositions\n - 05 - Energy / 06 - Weak Points and Strong\n - 07 - Maneuvering / 08 - Variation in Tactics\n - 09 - The Army on the March / 10 - Terrain\n - 11 - The Nine Situations\n - 12 - The Attack By Fire / 13 - The Use of Spies\n\nmake_audiobook::create_project::workspace: \"%{hiera('top')}/%{::appname}\"\nmake_audiobook::create_project::appname: \"%{::appname}\"\nmake_audiobook::create_project::package_name: \"%{hiera('package')}\"\nmake_audiobook::create_project::android: '/home/plankton/android-sdk-linux/tools/android'\n\nmake_audiobook::generate_keystore::top: \"%{hiera('top')}\"\nmake_audiobook::generate_keystore::password: \"%{hiera('password')}\"\nmake_audiobook::ant_debug::workspace: \"%{hiera('top')}/%{::appname}\"\n\nmake_audiobook::app_mp3files::app_zip_url: 'http://www.archive.org/download/art_of_war_librivox/art_of_war_librivox_64kb_mp3.zip'\nmake_audiobook::app_mp3files::resource_path: \"%{hiera('top')}/%{::appname}/%{::appname}\"\n\nmake_audiobook::app_drawables::path_to_drawables: \"%{hiera('top')}/%{::appname}/%{::appname}/res/drawable-hdpi\" \n"
To generate yaml:
import yaml
data = {...} # python datastructure
yaml.dump(data, default_flow_style=False) # second parameter specifies block style yaml.
to generate nicely indented json:
print json.dumps(data, indent=4)
if you have yaml and want json:
print json.dumps(yaml.load(...), indent=4)

Homebrew + Python on mac os x 10.8: Fatal Python error: PyThreadState_Get: no current thread importing mapnik

I have 2 pythons on my mac (10.8.3): The default, and 2.7 version from homebrew.
So far, I could install modules and use them with my brew python. I installed mapnik with brew install mapnik (mapnik-2.1.0) and it compiled correctly. But, if I open python and enter import mapnik, the following error comes and python exits:
>>> import mapnik
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
Mac os x also shows an error window, with the following content:
Process: Python [60666]
Path: /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: 2.7.3 (2.7.3)
Code Type: X86-64 (Native)
Parent Process: bash [60454]
User ID: 501
Date/Time: 2013-03-28 10:21:08.535 +0100
OS Version: Mac OS X 10.8.3 (12D78)
Report Version: 10
Interval Since Last Report: 128837 sec
Crashes Since Last Report: 5
Per-App Crashes Since Last Report: 4
Anonymous UUID: 567121E6-7BAC-335F-E3B0-DD24D1F9E6BA
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Application Specific Information:
abort() called
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff94500d46 __kill + 10
1 libsystem_c.dylib 0x00007fff92afddf0 abort + 177
2 org.python.python 0x0000000105a77eaa Py_FatalError + 49
3 org.python.python 0x0000000105a76370 PyThreadState_Get + 28
4 org.python.python 0x0000000105a71f16 Py_InitModule4_64 + 58
5 libboost_python-mt.dylib 0x0000000104153288 boost::python::detail::init_module(char const*, void (*)()) + 40
6 org.python.python 0x00000001029fa716 _PyImport_LoadDynamicModule + 150
7 org.python.python 0x00000001029fa428 import_submodule + 296
8 org.python.python 0x00000001029f9ff1 load_next + 268
9 org.python.python 0x00000001029f80fb PyImport_ImportModuleLevel + 794
10 org.python.python 0x00000001029de9d3 builtin___import__ + 132
11 org.python.python 0x000000010296e335 PyObject_Call + 101
12 org.python.python 0x00000001029e8e10 PyEval_CallObjectWithKeywords + 93
13 org.python.python 0x00000001029e61b6 PyEval_EvalFrameEx + 11727
14 org.python.python 0x00000001029e32bd PyEval_EvalCodeEx + 1638
15 org.python.python 0x00000001029e2c51 PyEval_EvalCode + 54
16 org.python.python 0x00000001029f6e58 PyImport_ExecCodeModuleEx + 247
17 org.python.python 0x00000001029f99bf load_source_module + 1053
18 org.python.python 0x00000001029f9c7e load_package + 334
19 org.python.python 0x00000001029fa428 import_submodule + 296
20 org.python.python 0x00000001029f9ff1 load_next + 268
21 org.python.python 0x00000001029f80fb PyImport_ImportModuleLevel + 794
22 org.python.python 0x00000001029de9d3 builtin___import__ + 132
23 org.python.python 0x000000010296e335 PyObject_Call + 101
24 org.python.python 0x00000001029e8e10 PyEval_CallObjectWithKeywords + 93
25 org.python.python 0x00000001029e61b6 PyEval_EvalFrameEx + 11727
26 org.python.python 0x00000001029e32bd PyEval_EvalCodeEx + 1638
27 org.python.python 0x00000001029e2c51 PyEval_EvalCode + 54
28 org.python.python 0x0000000102a01a2b run_mod + 53
29 org.python.python 0x0000000102a0184d PyRun_InteractiveOneFlags + 365
30 org.python.python 0x0000000102a01367 PyRun_InteractiveLoopFlags + 188
31 org.python.python 0x0000000102a01218 PyRun_AnyFileExFlags + 60
32 org.python.python 0x0000000102a120b2 Py_Main + 3210
33 libdyld.dylib 0x00007fff966bf7e1 start + 1
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x00007fff5d29c2b0 rcx: 0x00007fff5d29c298 rdx: 0x0000000000000000
rdi: 0x000000000000ecfa rsi: 0x0000000000000006 rbp: 0x00007fff5d29c2c0 rsp: 0x00007fff5d29c298
r8: 0x00000000000003f5 r9: 0x00007fff5d29c270 r10: 0x00007fff94502342 r11: 0x0000000000000206
r12: 0x00007fff5d29cb00 r13: 0x0000000102e9b656 r14: 0x00000000000003f5 r15: 0x0000000000000000
rip: 0x00007fff94500d46 rfl: 0x0000000000000206 cr2: 0x00007fff7bff7ff0
Logical CPU: 0
Binary Images:
0x102961000 - 0x102961fff +org.python.python (2.7.3 - 2.7.3) <62DA7BCA-2A0C-3753-A043-7459827F56D1> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
0x102964000 - 0x102a6cfff +org.python.python (2.7.3, [c] 2004-2012 Python Software Foundation. - 2.7.3) <81E6FB4A-287C-37C3-A26D-D045B604933F> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Python
0x102c4c000 - 0x102c4efff +readline.so (0) <C4F1219C-CDFD-37D2-A762-22974D3F2918> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so
0x102c54000 - 0x102c77fff +libreadline.6.2.dylib (6.2) <2131C2A4-E75D-3680-9C8D-E42D78A5E1B9> /usr/local/opt/readline/lib/libreadline.6.2.dylib
0x102cfc000 - 0x102d01fff +itertools.so (0) <F857A819-40A9-3F72-A0B1-3E97BA5F3DAA> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/itertools.so
0x102d0a000 - 0x102f2cfff +_mapnik.so (0) <433DAD47-AB4D-37C5-A0EA-FE1134B63D3D> /usr/local/lib/python2.7/site-packages/mapnik/_mapnik.so
0x103603000 - 0x103978ff7 +libmapnik.dylib (0) <0E898678-9D86-35B4-A772-0248924F5BF3> /usr/local/Cellar/mapnik/2.1.0/lib/libmapnik.dylib
0x104138000 - 0x104170ff7 +libboost_python-mt.dylib (0) <9B5DD680-BEC9-3988-9F55-F59DA38CC175> /usr/local/lib/libboost_python-mt.dylib
0x1041b3000 - 0x1041c2ff7 +libboost_thread-mt.dylib (0) <24432300-9373-30B6-89F6-857CBEF9C105> /usr/local/lib/libboost_thread-mt.dylib
0x1041de000 - 0x10424dff7 +libfreetype.6.dylib (0) <490EDE42-5B78-34BA-85E7-D0547BE778E1> /usr/local/lib/libfreetype.6.dylib
0x104262000 - 0x104268fff +libltdl.7.dylib (0) <E437E59F-FC2E-3837-BDF8-301BEF13C7D6> /usr/local/lib/libltdl.7.dylib
0x10426c000 - 0x10428bff7 +libpng15.15.dylib (0) <52907DBF-A04C-325D-9E77-DF56A771026F> /usr/local/lib/libpng15.15.dylib
0x104293000 - 0x1042e6fff +libtiff.5.dylib (0) <AE85D7B1-F4E5-3B27-832D-5756EFCDE912> /usr/local/lib/libtiff.5.dylib
0x1042f2000 - 0x104326fff +libproj.0.dylib (0) <C799D9A7-0DDA-334D-9AEA-13A4AE7A67A2> /usr/local/lib/libproj.0.dylib
0x104333000 - 0x104441ff7 +libicuuc.50.1.dylib (0) <5FDBBF25-EEA6-3649-9ED6-B18CE89CE510> /usr/local/opt/icu4c/lib/libicuuc.50.1.dylib
0x1044a3000 - 0x1044b2fff +libboost_filesystem-mt.dylib (0) <B2C03485-5FA6-3744-BC99-DB4E87DA4D87> /usr/local/lib/libboost_filesystem-mt.dylib
0x1044c3000 - 0x1044c5ff7 +libboost_system-mt.dylib (0) <FE5E6E11-C7FB-3895-9976-526D22997EDC> /usr/local/lib/libboost_system-mt.dylib
0x1044ca000 - 0x104578fff +libboost_regex-mt.dylib (0) <BC1D7F46-F6AB-3964-B344-E692EFC5D3B7> /usr/local/lib/libboost_regex-mt.dylib
0x10461c000 - 0x10464bff7 +libjpeg.8.dylib (0) <9EC07360-CF18-3529-AE54-E60DBF1313DC> /usr/local/lib/libjpeg.8.dylib
0x104652000 - 0x105a24fff +libicudata.50.dylib (0) <B74D5789-7082-3084-9BF0-9A3AE6F2B046> /usr/local/opt/icu4c/lib/libicudata.50.dylib
0x105a26000 - 0x105b33fff org.python.python (2.7.2 - 2.7.2) <E7F3EED1-E55D-32AF-9649-77C814693F6A> /System/Library/Frameworks/Python.framework/Versions/2.7/Python
0x7fff62561000 - 0x7fff6259593f dyld (210.2.3) <36CAA36E-72BC-3E48-96D9-B96A2DF77730> /usr/lib/dyld
0x7fff8ae57000 - 0x7fff8ae7cff7 libc++abi.dylib (26) <D86169F3-9F31-377A-9AF3-DB17142052E4> /usr/lib/libc++abi.dylib
0x7fff8c50f000 - 0x7fff8c510ff7 libsystem_sandbox.dylib (220.2) <6838A6FD-8626-3356-BB4F-BB4787216207> /usr/lib/system/libsystem_sandbox.dylib
0x7fff8c511000 - 0x7fff8c523ff7 libz.1.dylib (43) <2A1551E8-A272-3DE5-B692-955974FE1416> /usr/lib/libz.1.dylib
0x7fff8d337000 - 0x7fff8d342fff libsystem_notify.dylib (98.5) <C49275CC-835A-3207-AFBA-8C01374927B6> /usr/lib/system/libsystem_notify.dylib
0x7fff8d9e6000 - 0x7fff8d9ebfff libcompiler_rt.dylib (30) <08F8731D-5961-39F1-AD00-4590321D24A9> /usr/lib/system/libcompiler_rt.dylib
0x7fff8dd72000 - 0x7fff8dd73fff libDiagnosticMessagesClient.dylib (8) <8548E0DC-0D2F-30B6-B045-FE8A038E76D8> /usr/lib/libDiagnosticMessagesClient.dylib
0x7fff902d7000 - 0x7fff90326ff7 libcorecrypto.dylib (106.2) <CE0C29A3-C420-339B-ADAA-52F4683233CC> /usr/lib/system/libcorecrypto.dylib
0x7fff9064f000 - 0x7fff90650fff libsystem_blocks.dylib (59) <D92DCBC3-541C-37BD-AADE-ACC75A0C59C8> /usr/lib/system/libsystem_blocks.dylib
0x7fff90a75000 - 0x7fff90a7dff7 libsystem_dnssd.dylib (379.37) <616FC901-151E-38BF-B2C4-24A351C5FAAD> /usr/lib/system/libsystem_dnssd.dylib
0x7fff914fd000 - 0x7fff9150afff libbz2.1.0.dylib (29) <CE9785E8-B535-3504-B392-82F0064D9AF2> /usr/lib/libbz2.1.0.dylib
0x7fff92899000 - 0x7fff928a7fff libcommonCrypto.dylib (60027) <BAAFE0C9-BB86-3CA7-88C0-E3CBA98DA06F> /usr/lib/system/libcommonCrypto.dylib
0x7fff92aa4000 - 0x7fff92b70ff7 libsystem_c.dylib (825.26) <4C9EB006-FE1F-3F8F-8074-DFD94CF2CE7B> /usr/lib/system/libsystem_c.dylib
0x7fff92bba000 - 0x7fff92bc0ff7 libunwind.dylib (35.1) <21703D36-2DAB-3D8B-8442-EAAB23C060D3> /usr/lib/system/libunwind.dylib
0x7fff92ed3000 - 0x7fff92f3cfff libstdc++.6.dylib (56) <EAA2B53E-EADE-39CF-A0EF-FB9D4940672A> /usr/lib/libstdc++.6.dylib
0x7fff93019000 - 0x7fff93065ff7 libauto.dylib (185.1) <73CDC482-16E3-3FC7-9BB4-FBA2DA44DBC2> /usr/lib/libauto.dylib
0x7fff930cf000 - 0x7fff930d5fff libmacho.dylib (829) <BF332AD9-E89F-387E-92A4-6E1AB74BD4D9> /usr/lib/system/libmacho.dylib
0x7fff93177000 - 0x7fff93199ff7 libxpc.dylib (140.42) <BBE558BD-5E55-35E4-89ED-1AA6B056D05A> /usr/lib/system/libxpc.dylib
0x7fff931f6000 - 0x7fff931f7ff7 libremovefile.dylib (23.2) <6763BC8E-18B8-3AD9-8FFA-B43713A7264F> /usr/lib/system/libremovefile.dylib
0x7fff931f8000 - 0x7fff93260ff7 libc++.1.dylib (65.1) <20E31B90-19B9-3C2A-A9EB-474E08F9FE05> /usr/lib/libc++.1.dylib
0x7fff9345d000 - 0x7fff9365dfff libicucore.A.dylib (491.11.2) <FD6282D8-DF3F-3842-8C2E-CF478D2B9669> /usr/lib/libicucore.A.dylib
0x7fff9365e000 - 0x7fff9365efff libkeymgr.dylib (25) <CC9E3394-BE16-397F-926B-E579B60EE429> /usr/lib/system/libkeymgr.dylib
0x7fff936d4000 - 0x7fff936dcfff liblaunch.dylib (442.26.2) <2F71CAF8-6524-329E-AC56-C506658B4C0C> /usr/lib/system/liblaunch.dylib
0x7fff9424d000 - 0x7fff9427bff7 libsystem_m.dylib (3022.6) <B434BE5C-25AB-3EBD-BAA7-5304B34E3441> /usr/lib/system/libsystem_m.dylib
0x7fff94284000 - 0x7fff94286fff libquarantine.dylib (52) <4BE2E642-A14F-340A-B482-5BD2AEFD9C24> /usr/lib/system/libquarantine.dylib
0x7fff94381000 - 0x7fff94382ff7 libdnsinfo.dylib (453.19) <14202FFB-C3CA-3FCC-94B0-14611BF8692D> /usr/lib/system/libdnsinfo.dylib
0x7fff944ef000 - 0x7fff9450aff7 libsystem_kernel.dylib (2050.22.13) <5A961E2A-CFB8-362B-BC43-122704AEB047> /usr/lib/system/libsystem_kernel.dylib
0x7fff94579000 - 0x7fff94587ff7 libsystem_network.dylib (77.10) <0D99F24E-56FE-380F-B81B-4A4C630EE587> /usr/lib/system/libsystem_network.dylib
0x7fff94821000 - 0x7fff9493992f libobjc.A.dylib (532.2) <90D31928-F48D-3E37-874F-220A51FD9E37> /usr/lib/libobjc.A.dylib
0x7fff9493a000 - 0x7fff9494fff7 libdispatch.dylib (228.23) <D26996BF-FC57-39EB-8829-F63585561E09> /usr/lib/system/libdispatch.dylib
0x7fff95c25000 - 0x7fff95d22ff7 libxml2.2.dylib (22.3) <47B09CB2-C636-3024-8B55-6040F7829B4C> /usr/lib/libxml2.2.dylib
0x7fff96350000 - 0x7fff96351ff7 libSystem.B.dylib (169.3) <9089D72D-E714-31E1-80C8-698A8E8B05AD> /usr/lib/libSystem.B.dylib
0x7fff96397000 - 0x7fff9639cfff libcache.dylib (57) <65187C6E-3FBF-3EB8-A1AA-389445E2984D> /usr/lib/system/libcache.dylib
0x7fff96646000 - 0x7fff9664dfff libcopyfile.dylib (89) <876573D0-E907-3566-A108-577EAD1B6182> /usr/lib/system/libcopyfile.dylib
0x7fff966bd000 - 0x7fff966c0ff7 libdyld.dylib (210.2.3) <F59367C9-C110-382B-A695-9035A6DD387E> /usr/lib/system/libdyld.dylib
0x7fff96961000 - 0x7fff96963ff7 libunc.dylib (25) <92805328-CD36-34FF-9436-571AB0485072> /usr/lib/system/libunc.dylib
0x7fff974ba000 - 0x7fff974f0fff libsystem_info.dylib (406.17) <4FFCA242-7F04-365F-87A6-D4EFB89503C1> /usr/lib/system/libsystem_info.dylib
0x7fff97850000 - 0x7fff97888fff libncurses.5.4.dylib (37.3) <68D5B5F5-8252-3F1E-AFF1-C6AFE145DBC1> /usr/lib/libncurses.5.4.dylib
0x7fff978d3000 - 0x7fff97abdff7 com.apple.CoreFoundation (6.8 - 744.18) <A60C3C9B-3764-3291-844C-C487ACF77C2C> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 18730
thread_create: 2
thread_set_state: 0
VM Region Summary:
ReadOnly portion of Libraries: Total=109.5M resident=53.3M(49%) swapped_out_or_unallocated=56.2M(51%)
Writable regions: Total=20.6M written=2644K(13%) resident=3256K(15%) swapped_out=0K(0%) unallocated=17.5M(85%)
REGION TYPE VIRTUAL
=========== =======
MALLOC 11.8M
MALLOC guard page 32K
STACK GUARD 56.0M
Stack 8192K
__DATA 2356K
__LINKEDIT 68.3M
__TEXT 41.2M
__UNICODE 544K
shared memory 12K
=========== =======
TOTAL 188.2M
Model: MacBookPro8,2, BootROM MBP81.0047.B27, 4 processors, Intel Core i7, 2 GHz, 8 GB, SMC 1.69f4
Graphics: Intel HD Graphics 3000, Intel HD Graphics 3000, Built-In, 512 MB
Graphics: AMD Radeon HD 6490M, AMD Radeon HD 6490M, PCIe, 256 MB
Memory Module: BANK 0/DIMM0, 4 GB, DDR3, 1333 MHz, 0x80CE, 0x4D34373142353237334348302D4348392020
Memory Module: BANK 1/DIMM0, 4 GB, DDR3, 1333 MHz, 0x80CE, 0x4D34373142353237334348302D4348392020
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0xD6), Broadcom BCM43xx 1.0 (5.106.98.100.16)
Bluetooth: Version 4.1.3f3 11349, 2 service, 11 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en1
Serial ATA Device: ST9500420AS, 500.11 GB
Serial ATA Device: MATSHITADVD-R UJ-898
USB Device: FaceTime HD Camera (Built-in), apple_vendor_id, 0x8509, 0xfa200000 / 3
USB Device: hub_device, 0x0424 (SMSC), 0x2513, 0xfa100000 / 2
USB Device: Apple Internal Keyboard / Trackpad, apple_vendor_id, 0x0246, 0xfa120000 / 5
USB Device: BRCM2070 Hub, 0x0a5c (Broadcom Corp.), 0x4500, 0xfa110000 / 4
USB Device: Bluetooth USB Host Controller, apple_vendor_id, 0x821a, 0xfa113000 / 8
USB Device: hub_device, 0x0424 (SMSC), 0x2513, 0xfd100000 / 2
USB Device: IR Receiver, apple_vendor_id, 0x8242, 0xfd110000 / 3
Any problems with linking my pythons? how can I fix it? thanks!
It looks like you are running the homebrew python but either boost python or mapnik's python bindings ended up linking against the system python provided by apple. If a full clean and reinstall of boost and Mapnik does not fix this then I recommend stopping by #mapnik irc on freenode for help debugging. Generally to fix you need to call otool -L on boost_python.dylib and or on site_packages/mapnik/_mapnik.so to see which ended up with a linkage to the system python. Then you can fix by using install_name_tool.
I encountered the same problem between python27-apple and python27 (installed by Macport). I tried these steps, and it worked for me.
According to #Evert's comments of different libraries used by different python, I tried to revert the python27-apple to be "active".
sudo port select --list python
For my computer, it showed:
Available versions for python:
none
python25-apple
python26
python26-apple
python27 (active)
python27-apple
in which python27(by Macport) was currently active. Then,
sudo port select python python27-apple
to make python27-apple active as the default lib were called previously. To double check,
sudo port select --list python
It now showed:
Available versions for python:
none
python25-apple
python26
python26-apple
python27
python27-apple (active)
And the python crash had gone when I ran the scripts.
You can use the homebrew python like this:
/usr/bin/python2.7 yourscript.py
I face the similar problem in using androguard. Though it's not quite the same, it can be a reference. My crash also is Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6. Run otool -L <lib>, suggest the dylib link to the system python.
Try solution:
python-config --ldflags
Copy the output to corresponding MakeFile. For example change LDFLAGS += -lm -lbz2 -lz -llzma -lsnappy -lmuparser -lpython to LDFLAGS += -lm -lbz2 -lz -llzma -lsnappy -lmuparser -L/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config -lpython2.7 -ldl -framework CoreFoundation.
make clean, then make again.
Now the dylib is OK, and no error anymore.
Alternatively ...
... when you use otool -L <lib> to find the wrongly linked python dylib you can use install_name_tool to change the symbol like:
install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python /usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib <lib>

Categories