tag:blogger.com,1999:blog-41236855534415317632024-03-19T04:24:36.601-07:00Generics 3.0Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.comBlogger79125tag:blogger.com,1999:blog-4123685553441531763.post-1393751903210195112019-08-22T12:48:00.000-07:002019-08-22T12:48:01.512-07:00Django - Field 'name' doesn't have a default value<div dir="ltr" style="text-align: left;" trbidi="on">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
<br />
<div class="p1">
<span class="s1">When running django migration you run into following error - </span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">> python manage.py migrate</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">.........</span></div>
<div class="p1">
<span class="s1"><span class="Apple-converted-space"> </span>File "/usr/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute</span></div>
<br />
<div class="p1">
<span class="s1"><span class="Apple-converted-space"> </span>self.errorhandler(self, exc, value)</span></div>
<div class="p1">
<span class="s1"><span class="Apple-converted-space"> </span>File "/usr/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler</span></div>
<div class="p1">
<span class="s1">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
</span></div>
<div class="p1">
<span class="s1"><span class="Apple-converted-space"> </span>raise errorclass, errorvalue</span></div>
<br />
<div class="p1">
<span class="s1">django.db.utils.OperationalError: (1364, "Field 'name' doesn't have a default value")</span></div>
<br /><br />
<br />
It's due to django_content_type table, where name column property is not allowing to get the migration run completing successfully as the column constraint is causing the failure.<br />
<br />
Running following sql command would solve the issue -<br />
<br />
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
<br />
<div class="p1">
<span class="s1">ALTER TABLE django_content_type MODIFY COLUMN name character varying(50) NOT NULL DEFAULT 'not null';</span></div>
<br /></div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-66110171208802841932018-10-25T19:40:00.003-07:002018-10-25T19:40:37.093-07:00macOS Mojave doesn't recognize git<div dir="ltr" style="text-align: left;" trbidi="on">
<div>
<br /></div>
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
<br />
Who doesn't want dark mode on mac!<br /><br />However, after updating the macOs to Mojave, if you try to access git on your command prompt, it throws below error - <div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1"><span style="font-family: Courier New, Courier, monospace;">$ git</span></span></div>
<div class="p1">
<span class="s1"><span style="font-family: Courier New, Courier, monospace;">xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun</span></span></div>
<br /><br />
All you need to do is reinstall the xcode command line tool using following command -<br />
<br />
<span style="background-color: white; color: #242729; font-size: 13px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit; white-space: inherit;"><span style="font-family: Courier New, Courier, monospace;">$xcode-select --install</span></span><br />
<br />It should run fine after that. <br /></div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-56924081568846808112018-06-21T06:21:00.000-07:002018-06-21T06:21:10.562-07:00GNU Octave - unable to run gnuplot <div dir="ltr" style="text-align: left;" trbidi="on">
While going thru the <a href="https://www.coursera.org/learn/machine-learning">coursera machine learning</a> course exercise, I ran into below issue. It wouldn't allow to run some of the exercise code. <br />
<br />
<span style="font-family: Courier New, Courier, monospace;">gnuplot> set terminal aqua enhanced title "Figure 1" size 560 420 font "*,6" dashlength 1</span><br />
<span style="font-family: Courier New, Courier, monospace;"> ^</span><br />
<span style="font-family: Courier New, Courier, monospace;"> line 0: unknown or ambiguous terminal type; type just 'set terminal' for a list</span><br />
<br />
<span style="font-family: Courier New, Courier, monospace;">WARNING: Plotting with an 'unknown' terminal.</span><br />
<span style="font-family: Courier New, Courier, monospace;">No output will be generated. Please select a terminal with 'set terminal'.</span><br />
<br />
It's because we need to setup proper environment for it. Here is the quick solution -<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">>setenv("GNUTERM","qt")</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Happy Learning!</span></div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-2168693678197454002017-07-26T06:25:00.000-07:002017-07-26T06:25:42.671-07:00Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (LoadError)<div dir="ltr" style="text-align: left;" trbidi="on">
I had grunt process defined to compile the sass files, it was working fine until I had to reinstall my brew and it end up breaking the sass compile compass. Below was the setting -<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">compass: {</span><br />
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"> options: {</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"> cssDir: 'static/css',</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"> raw: 'Sass::Script::Number.precision = 10\n::Encoding.default_external = \'utf-8\'\n',</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"> sourcemap: true</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"> },</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"> styleSass: {</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"> options: {</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"> sassDir: '<%= appConfig.src.sass %>',</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"> specify: ['<%= appConfig.src.sass %>/demo.sass', '<%= appConfig.src.sass %>/style.sass']</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"> }</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"> },</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">....</span></div>
<br />On running the grunt, it failed with following error -<br /><br />
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Andale Mono'; color: #28fe14; background-color: #000000; background-color: rgba(0, 0, 0, 0.8)}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Andale Mono'; color: #afad24; background-color: #000000; background-color: rgba(0, 0, 0, 0.8)}
span.s1 {text-decoration: underline ; font-variant-ligatures: no-common-ligatures}
span.s2 {font-variant-ligatures: no-common-ligatures}
span.Apple-tab-span {white-space:pre}
</style>
<div class="p1">
<span class="s1">Running "compass:styleSass" (compass) task</span></div>
<div class="p2">
<span class="s2">Warning: Command failed: /bin/sh -c compass --version</span></div>
<div class="p2">
<span class="s2">/Users/J/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:126:in `require': dlopen(/Users/J/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/x86_64-darwin14.1.0/digest/sha1.bundle, 9): Library not loaded: <b><span style="color: red; font-size: small;">/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (LoadError)</span></b></span></div>
<div class="p2">
<span class="s2"><span class="Apple-converted-space"> </span>Referenced from: /Users/J/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/x86_64-darwin14.1.0/digest/sha1.bundle</span></div>
<div class="p2">
<span class="s2"><span class="Apple-converted-space"> </span>Reason: image not found - /Users/J/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/x86_64-darwin14.1.0/digest/sha1.bundle</span></div>
<div class="p2">
<span class="s2"><span class="Apple-tab-span"> </span>from /Users/J/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:126:i</span></div>
<div>
<br /></div>
if you run into an issue, do the following to fix it -<div>
<br /></div>
<div>
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Andale Mono'; color: #28fe14; background-color: #000000; background-color: rgba(0, 0, 0, 0.8)}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
<div class="p1">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Andale Mono'; color: #28fe14; background-color: #000000; background-color: rgba(0, 0, 0, 0.8)}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
</div>
<div class="p1">
<span class="s1">$ brew remove openssl</span></div>
<div class="p1">
<span class="s1">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Andale Mono'; color: #28fe14; background-color: #000000; background-color: rgba(0, 0, 0, 0.8)}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
</span></div>
<div class="p1">
<span class="s1">$ brew install openssl</span></div>
</div>
<div>
or </div>
<div>
<br /></div>
<div>
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Andale Mono'; color: #28fe14; background-color: #000000; background-color: rgba(0, 0, 0, 0.8)}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
<div class="p1">
<span class="s1">$ brew reinstall openssl</span></div>
</div>
<div>
<br /></div>
<div>
It should fix it!</div>
</div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-27436105655367120982017-07-25T08:14:00.000-07:002017-07-25T08:15:43.121-07:00Cannot read property 'localeCompare' of undefined<div dir="ltr" style="text-align: left;" trbidi="on">
While running npm install, I ran into following error -<br />
<br />
<span style="color: #e06666;">npm WARN engine webpack@2.7.0: wanted: {"node":">=4.3.0 =5.10"} (current: {"node":"5.0.0","npm":"3.3.6"})<br />npm ERR! Darwin 16.6.0<br />npm ERR! argv "/Users/J/.nvm/versions/node/v5.0.0/bin/node" "/Users/J/.nvm/versions/node/v5.0.0/bin/npm" "install"<br />npm ERR! node v5.0.0<br />npm ERR! npm v3.3.6<br /><br />npm ERR! Cannot read property 'localeCompare' of undefined<br />npm ERR! <br />npm ERR! If you need help, you may report this error at:<br />npm ERR! <br />npm ERR! Please include the following file with any support request:<br />npm ERR! /Users/Jaimin/Apps/redesign/data-exploration/npm-debug.log</span><br />
mostly you will run into this issue if you are running npm 3.3.5 or 3.3.6.<br />
<br />
You can try resolve it by below two ways,<br />
<br />
1. Remove all node_modules folder, and try to run 'npm install' again.<br />
<br />
If above doesn't resolve it, try below -<br />
<br />
2. upgrade npm to 3.3.7 (or any subsequent one)<br />
npm install npm@3.3.7 -g<br />
<br />
It should resolve the issue. If you want to read up various other suggestions/reasoning checkout <a href="https://github.com/npm/npm/issues/9766">here</a>. </div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-15194396549099477212017-06-11T06:49:00.000-07:002017-06-11T06:49:32.511-07:00Instaling TensorFlow on mac OSX Yosemite<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
I wanted to try out <a href="https://www.tensorflow.org/">TensorFlow</a>, so I started with the installation steps. First create virtualenv, and then try to do pip install, there are bunch of different ways you can install as per the instructions provided <a href="https://www.tensorflow.org/install/install_mac">here</a>, though I went with below and it at least for the first part installed it right.<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">pip install --ignore-installed --upgrade \ https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.1.0-py2-none-any.whl</span><br />
<br />
Above is CPU-only installation with Anaconda. My mac default python runs under anaconda, so above worked well for me compared to other installation mechanism described in documentation.<br />
<br />
After the installation I followed below step to try out test of tensorflow installation success -<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">$ python</span><br />
<span style="font-family: Courier New, Courier, monospace;">>> import tensorflow as tf</span><br />
<br />
Though I ran into error -<br />
<span style="color: red;"> <span style="font-family: Courier New, Courier, monospace;"> _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) </span></span><br />
<span style="color: red; font-family: Courier New, Courier, monospace;">ImportError: numpy.core.multiarray failed to import</span><br />
<br />
It was because of the numpy, it was pointing to the wrong one. I tried below to check the path of numpy -<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">$ python</span><br />
<span style="font-family: Courier New, Courier, monospace;">>> import numpy</span><br />
<span style="font-family: Courier New, Courier, monospace;">>> print numpy.__path__</span><br />
<span style="font-family: Courier New, Courier, monospace;">['/usr/local/lib/python2.7/site-packages/numpy']</span><br />
<br />
Which is an issue, as its using /local/lib/python2.7 installation and not local virtualenv installation -<br />
Go to the path and remove the file explicitly. After that I tried again to review the path of numpy -<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">>> print numpy.__path__</span><br />
<span style="font-family: Courier New, Courier, monospace;">['/Users/jpatel/Apps/tensorflow/venv/lib/python2.7/site-packages/numpy']</span><br />
<br />
However, at this point I run into another error -<br />
<br />
<span style="color: red; font-family: Courier New, Courier, monospace;"> from google.protobuf import descriptor as _descriptor<br />ImportError: No module named protobuf<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Andale Mono'; color: #29f914; background-color: #000000}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style></span><div>
<br /></div>
<div>
Its because of issue with protobuf installation version, after looking at few of the online documentation help, I updated to below -</div>
<div>
<br /></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">$ pip uninstall protobuf</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">$ pip install protobuf==3.0.0a3</span></div>
<div>
<br /></div>
<div>
though error continues, </div>
<br /><span style="color: red; font-family: Courier New, Courier, monospace;"> from google.protobuf import any_pb2 as google_dot_protobuf_dot_any__pb2 <br />ImportError: cannot import name any_pb2</span><br /><br /><div>
so figured another version from online help -</div>
<br /><span style="font-family: Courier New, Courier, monospace;">$ pip install --upgrade protobuf==3.0.0b2</span><div>
<br /></div>
<div>
<br /></div>
<div>
After that it started working fine. -</div>
<div>
<br /></div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace;">>>> import tensorflow as tf</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">>>> hello = tf.constant("Hello, TensorFlow")</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">>>> sess = tf.Session()</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">2017-06-11 09:45:35.310965: W t</span></div>
<div>
<span style="font-family: "Courier New", Courier, monospace;">>>> print(sess.run(hello))</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">Hello, TensorFlow</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">>>> node1 = tf.constant(3.0, tf.float32)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">>>> node2 = tf.constant(4.0)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">>>> print(node1, node2)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">(<tf .tensor="" dtype="float32" onst_1:0="" shape="()">, <tf .tensor="" dtype="float32" onst_2:0="" shape="()">)</tf></tf></span></div>
</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
If I do more experimentation around it, will share more examples and issues I run into and how to solve..</div>
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Andale Mono'; color: #29f914; background-color: #000000}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Andale Mono'; color: #29f914; background-color: #000000}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style></div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-63952999337961093552017-04-15T20:52:00.000-07:002017-04-15T20:52:09.516-07:00Generic relations in Django<div dir="ltr" style="text-align: left;" trbidi="on">
While using django's content management system (admin), for adding different objects on it, you may want things like audit notes, that can be used for reference in the future or get some more info. you have two choice -<br />
<br />
<br />
<ol style="text-align: left;">
<li>Add a explicit field to the object, though the down side is you will need to add that extra field with all the objects where you want note.</li>
<li>Create a generic model which can be used with different objects in your app. </li>
</ol>
<br />
It's no brainer between above two choice, answer is 2nd. <a href="https://docs.djangoproject.com/ja/1.9/ref/contrib/contenttypes/#generic-relations">Generic relations</a> are at help.<br />
<br />
You can checkout <a href="https://github.com/django/django-contrib-comments">django-contrib-comments</a>, it's one of the example of generic relations. Let's take example of how Notes like foreign key reference can be added freely to any model in your app.<br />
<br />
<b>notes/models.py</b><br />
<span style="font-family: Courier New, Courier, monospace;">from django.contrib.contenttypes.fields import GenericForeignKey</span><br />
<span style="font-family: Courier New, Courier, monospace;">from django.contrib.contenttypes.models import ContentType</span><br />
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace;">class Note(models.Model):</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> note = models.TextField("note",</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> max_length=2000)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> date = models.DateTimeField(auto_now_add=True)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> # Below the mandatory fields for generic relation</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> content_type = models.ForeignKey(</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> ContentType, on_delete=models.CASCADE)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> object_id = models.PositiveIntegerField()</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> content_object = GenericForeignKey('content_type', 'object_id')</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> class Meta:</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> verbose_name = 'Staff Note'</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> def __unicode__(self):</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> return self.date.strftime("%B %d, %Y")</span></div>
</div>
<br />
<br />
Now, this Notes object can be referenced with any other model you want to use it with. Here is one example -<br />
<b><br /></b>
<b>mymodel/models.py</b><br />
<span style="font-family: Courier New, Courier, monospace;">from django.contrib.contenttypes.fields import GenericRelation</span><br />
<div>
<span style="font-family: Courier New, Courier, monospace;">from notes.models import Note</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<span style="font-family: Courier New, Courier, monospace;">class MyModel(models.Model):</span><br />
<span style="font-family: Courier New, Courier, monospace;"> name = models.CharField("Name", max_length=100)</span><br />
<span style="font-family: Courier New, Courier, monospace;"> notes = GenericRelation(Note)</span><br />
<div>
<br /></div>
<div>
When you run migration, it doesn't add anything in MyModel, as its generic relation it gets its references via django content type and object id.</div>
<div>
<br /></div>
<div>
How to add it in admin?</div>
<div>
<b><br /></b></div>
<div>
<b>notes/admin.py</b></div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace;">from django.contrib.contenttypes.admin import GenericTabularInline</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">from .models import Note</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace;">class NoteInline(GenericTabularInline):</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> model = Note</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> extra = 0</span></div>
</div>
<div style="font-weight: bold;">
<br /></div>
</div>
<div>
<b><br /></b></div>
<div>
<b>mymodel/admin.py</b></div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace;">from misc.admin import NoteInline</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">from .models import MyModel</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace;">class MyModelAdmin(admin.ModelAdmin):</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> inlines = [NoteInline, ]</span></div>
</div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace;">admin.site.register(MyModel, MyModelAdmin)</span></div>
</div>
<div>
<br /></div>
</div>
<div>
And you are all set. It's easy to plug, efficient, and clean implementation. Good luck!</div>
<div>
<br /></div>
</div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-36318603028858721082017-04-15T19:48:00.002-07:002017-04-15T19:51:00.968-07:00Django rest framework serializer with self-referential foreign key for comments<div dir="ltr" style="text-align: left;" trbidi="on">
Django had default comments package sometime back (django.contrib.comments), since it's deprecated, there is <a href="https://github.com/django/django-contrib-comments">external repo</a> available for now. It provides flat comments, so if you want threaded comments, you can use <a href="https://github.com/HonzaKral/django-threadedcomments">django-threadedcomments</a>.<br />
<br />
We are using <a href="http://www.django-rest-framework.org/">django-rest-framework</a>, and access the threaded comments via drf.<br />
<b><br /></b>
<b>resources.py</b><br />
<div style="color: #222222; font-family: arial, sans-serif; font-size: small;">
<br /></div>
<div style="color: #222222; font-size: small;">
<div>
<span style="font-family: "courier new" , "courier" , monospace;">class ObjectSerializer(serializers.<wbr></wbr>ModelSerializer):</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> comments = CommentsSerilizer(</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> source='comments_set',</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> many=True)</span></div>
</div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div style="color: #222222; font-size: small;">
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> class Meta:</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> model = ObjectName</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> fields = (</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> "id",</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> .....,</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> "comments",</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> )</span></div>
</div>
<div style="color: #222222; font-family: arial, sans-serif; font-size: small;">
<br /></div>
<div style="color: #222222; font-family: arial, sans-serif; font-size: small;">
<b><br /></b></div>
<div style="color: #222222; font-family: arial, sans-serif; font-size: small;">
<b>serializers.py</b></div>
<div style="color: #222222; font-family: arial, sans-serif; font-size: small;">
<br /></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;">from rest_framework import serializers</span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;">from .models import FluentComment</span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;">class RecursiveField(serializers.<wbr></wbr>Serializer):</span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;"> def to_representation(self, value):</span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;"> serializer = self.parent.parent.__class__(</span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;"> value,</span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;"> context=self.context)</span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;"> return serializer.data</span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;">class CommentsSerilizer(serializers.<wbr></wbr>ModelSerializer):</span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;"> children = RecursiveField(many=True)</span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;"> class Meta:</span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;"> model = FluentComment</span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;"> fields = (</span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;"> 'comment',</span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;"> 'url',</span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;"> 'submit_date',</span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;"> 'id',</span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;"> 'children',</span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;"> )</span></div>
<div style="color: #222222; font-size: small;">
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div style="color: #222222;">
<span class="" style="font-family: "times" , "times new roman" , serif;">Recursive Field is one way to get the self-referential objects via serializer, it handles parent-child relationship. Here is another way to do it -</span></div>
<div style="color: #222222;">
<span class="" style="font-family: "times" , "times new roman" , serif;"><br /></span></div>
<div>
<span class="" style="color: #222222;"></span><br />
<div style="font-family: "Courier New", Courier, monospace;">
<span class="" style="color: #222222;">class CommentsSerilizer(serializers.ModelSerializer):</span></div>
<span class="" style="color: #222222;">
<div style="font-family: "Courier New", Courier, monospace;">
user = UserLightSerializer()</div>
<div style="font-family: "Courier New", Courier, monospace;">
<br /></div>
<div style="font-family: "Courier New", Courier, monospace;">
class Meta:</div>
<div style="font-family: "Courier New", Courier, monospace;">
model = FluentComment</div>
<div style="font-family: "Courier New", Courier, monospace;">
fields = (</div>
<div style="font-family: "Courier New", Courier, monospace;">
'user',</div>
<div style="font-family: "Courier New", Courier, monospace;">
'comment',</div>
<div style="font-family: "Courier New", Courier, monospace;">
'submit_date',</div>
<div style="font-family: "Courier New", Courier, monospace;">
'id',</div>
<div style="font-family: "Courier New", Courier, monospace;">
'children',</div>
<div style="font-family: "Courier New", Courier, monospace;">
)</div>
<div style="font-family: "Courier New", Courier, monospace;">
<br /></div>
<div style="font-family: "Courier New", Courier, monospace;">
CommentsSerilizer._declared_fields[</div>
<div style="font-family: "Courier New", Courier, monospace;">
'children'] = CommentsSerilizer(many=True)</div>
<div style="font-family: "Courier New", Courier, monospace;">
<br /></div>
<div style="font-family: "Courier New", Courier, monospace;">
<br /></div>
<div>
<span style="font-family: "times" , "times new roman" , serif;">Above both options are fine, and it should do the magic. Good luck!</span></div>
</span></div>
</div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-90577617106491708892017-01-04T15:04:00.001-08:002017-01-04T15:04:14.284-08:00Limit celery concurrency workers to limit memory usage<div dir="ltr" style="text-align: left;" trbidi="on">
Limit the number of concurrent workers for celery message processing.<br />
<br />
We are using sentry for error logging and monitoring, and recently my sentry server moved from one shared server to another and with that it started crashing because of memory usage way over limit (shared server has limit of 1024MB and my celery worker was taking 2759MB).<br />
<br />
When I saw the log, I was surprised looking at number of worker processes -<br />
<br />
<span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 66MB - 0:06:45 - 21356 - [celeryd: celery@</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> servername:Worker</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">:MainProcess] -active- (celery worker -B)</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user - 68MB - 0:06:41 - 21657 - gunicorn: worker [Sentry]</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 69MB - 0:06:40 - 21658 - gunicorn: worker [Sentry]</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 61MB - 0:06:40 - 21659 - [celery beat]</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 61MB - 0:06:40 - 21660 - [celeryd: celery@servername:Worker-2]</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 61MB - 0:06:40 - 21661 - [celeryd: celery@</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">servername:Worker</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">-3]</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 61MB - 0:06:40 - 21662 - [celeryd: celery@</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">servername:Worker</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">-4]</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 61MB - 0:06:40 - 21663 - [celeryd: celery@</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">servername:Worker</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">-5]</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 61MB - 0:06:40 - 21664 - [celeryd: celery@</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">servername:</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">Worker-6]</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 59MB - 0:06:40 - 21665 - [celeryd: celery@</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">servername:</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">Worker-7]</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 59MB - 0:06:40 - 21666 - [celeryd: celery@</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">servername</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">:Worker-8]</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 61MB - 0:06:40 - 21667 - [celeryd: celery@servername:Worker-9]</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 59MB - 0:06:40 - 21668 - [celeryd: celery@</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">servername</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">:Worker-10]</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 61MB - 0:06:40 - 21669 - [celeryd: celery@</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">servername</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">:Worker-11]</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 61MB - 0:06:40 - 21670 - [celeryd: celery@</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">servername</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">:Worker-12]</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 59MB - 0:06:40 - 21671 - [celeryd: celery@</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">servername</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">:Worker-13]</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 61MB - 0:06:40 - 21672 - [celeryd: celery@</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">servername</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">:Worker-14]</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 59MB - 0:06:40 - 21673 - [celeryd: celery@</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">servername</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">:Worker-15]</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 59MB - 0:06:40 - 21675 - [celeryd: celery@</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">servername</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">:Worker-16]</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 61MB - 0:06:40 - 21677 - [celeryd: celery@</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">servername</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">:Worker-17]</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 61MB - 0:06:40 - 21678 - [celeryd: celery@</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">servername</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">:Worker-18]</span><br style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /><span style="color: #636363; font-family: Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="background-color: #f8f8f8; font-size: 13px;">.....</span></span><br />
<span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">user</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> - 61MB - 0:06:40 - 21678 - [celeryd: celery@</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">servername</span><span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">:Worker-44]</span><br />
<span style="background-color: #f8f8f8; color: #636363; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"><br /></span>
<br />Looking at above, obviously it was going to kill the process as the usage was going much higher than allowed.<br /><br />It was happening because of default concurrent process setting for celery. As per the <a href="http://docs.celeryproject.org/en/latest/reference/celery.bin.worker.html#cmdoption-celery-worker-c">documentation</a> -<div>
<br /></div>
<div>
<dt id="cmdoption-celery-worker-c" style="background: rgb(250, 243, 232); color: #3e4349; font-family: Optima, Segoe, "Segoe UI", Candara, Calibri, Arial, sans-serif; font-size: 17px;"><code class="descname" style="background-color: transparent; font-size: 1.2em; font-weight: bold;">-c</code><code class="descclassname" style="background-color: transparent;"></code><code class="descclassname" style="background-color: transparent;">, </code><code class="descname" style="background-color: transparent; font-size: 1.2em; font-weight: bold;">--concurrency</code><code class="descclassname" style="background-color: transparent;"></code><a class="headerlink" href="http://docs.celeryproject.org/en/latest/reference/celery.bin.worker.html#cmdoption-celery-worker-c" style="color: #dddddd; padding: 0px 4px; text-decoration: none; visibility: hidden;" title="Permalink to this definition"></a></dt>
<dd style="background-color: white; color: #3e4349; font-family: Optima, Segoe, "Segoe UI", Candara, Calibri, Arial, sans-serif; font-size: 17px; hyphens: auto; line-height: 1.4em; margin-bottom: 10px; margin-left: 30px; margin-top: 3px;"><div style="hyphens: auto; line-height: 1.4em;">
Number of child processes processing the queue. The default is the number of CPUs available on your system.</div>
</dd></div>
<div>
<br /></div>
<div>
In this case probably the number of CPU of the server was much higher. So the solution was to set the restriction by providing concurrency you want. </div>
<br /> <br />> celery worker -B --concurrency=4<div>
<br /></div>
<div>
It resolves the issue. You can validate number of celery process by - </div>
<br />> ps -ef | grep celeryd<br /><br />Hope it helps!<br /><br /><style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Andale Mono'; color: #29f914; background-color: #000000}
span.s1 {font-variant-ligatures: no-common-ligatures}
span.s2 {font-variant-ligatures: no-common-ligatures; background-color: #e6e600}
</style></div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-15408236165311307262016-12-17T06:02:00.000-08:002016-12-17T06:02:10.877-08:00RabbitMQ monitoring on New Relic - Webfaction<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">We are using celery with Django for some time now, and it uses RabbitMQ for the messaging backend. Sometimes post server updates, RabbitMQ goes down or due to heavy message load it slows down, in those cases currently we don't have any visibility. In order to monitor the queue, and get the the notification/alert in case of any alarming situation, we have setup monitoring on New Relic. Here are the steps - </span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="font-family: Arial;"><span style="font-size: 14.6667px; white-space: pre-wrap;">There are various choice for RabbitMQ monitoring on New Relic, but we used <a href="https://newrelic.com/plugins/poison-pen-llc/25">this</a> one. </span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<br /></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
On your server run following command - </div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">1> </span><span style="background-color: #f7f7f7; color: #333333; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">pip install newrelic-plugin-agent</span></div>
<b id="docs-internal-guid-760b911c-0d07-6fb7-39b0-7b9f6583d897" style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">If it’s dedicated server and you have full access, get configuration file </span><span style="background-color: transparent; color: #333333; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">/opt/newrelic-plugin-agent/newrelic-plugin-agent.cfg</span><span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> to </span><span style="background-color: transparent; color: #333333; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">/etc/newrelic/newrelic-plugin-agent.cfg</span><span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> and edit the configuration in that file. In my case its shared webfaction server, so we installed on /home/username/newrelic/ folder. (we created newrelic folder on the home).</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">2> Once create the newrelic folder, </span><span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;">copy </span><a href="https://gist.github.com/jpatel3/8f77ae6540ddee63e844e73fbd69de91" style="text-decoration: none;"><span style="background-color: white; color: #1155cc; font-family: Arial; font-size: 16px; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;">this sample</span></a><span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;"> config file there.</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Update the license key, user under Daemon (who has access to run the process, also make sure you give proper access to that user to the newrelic folder)</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">3> Update the settings for rabbitmq</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> rabbitmq:</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> name: PROD-RABBITMQ</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> host: localhost</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> port: 15672</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> verify_ssl_cert: false</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> username: <username></username></span></div>
<span id="docs-internal-guid-760b911c-0d0e-e5e9-7e87-62103e644cbb"><span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;"> password: <password></password></span></span><br />
<span><span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;"> vhosts:</span></span><br />
<span><span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;"> <prod host="" name="">:</prod></span></span><br />
<span><span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;"> queues: [<queu list="" name="">]</queu></span></span><br />
<span><span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;"><br /></span></span>
<span><span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;">In above vhosts is optional, if you have simple setup and not that many hosts and queues, you can skip that and it will monitor all. </span></span><br />
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; white-space: pre-wrap;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; white-space: pre-wrap;">4> To run in debug mode for testing - </span><br />
<span style="background-color: #f7f7f7; color: #333333; font-family: Consolas; font-size: 13.3333px; white-space: pre-wrap;">newrelic-plugin-agent -c newrelic-plugin-agent.cfg -f</span><br />
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="background-color: white; color: #333333; font-size: 16px;">Once you see that your setup is running fine, start it in background mode by removing -f</span></span></div>
<div dir="ltr" style="line-height: 1.74; margin-bottom: 12pt; margin-top: 0pt;">
<span style="background-color: #f7f7f7; color: #333333; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">newrelic-plugin-agent -c newrelic-plugin-agent.cfg</span></div>
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; white-space: pre-wrap;"><b><u>Notes - </u></b></span><br />
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; white-space: pre-wrap;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; white-space: pre-wrap;">It needs few things in order to this api calls to work for monitoring (Enable http UI for rabbitmq using rabbitmq_plugins)</span><br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #333333; font-family: "Courier New"; font-size: 13.3333px; white-space: pre-wrap;"><br /></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #333333; font-family: "Courier New"; font-size: 13.3333px; white-space: pre-wrap;">> rabbitmq-plugins enable rabbitmq_management</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Without enabling HTTP UI, it won’t be able to allow api access to monitoring service.</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">> once its enabled, you can try curl calls on /api on port 15672</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; vertical-align: baseline; white-space: pre-wrap;"><b><u>Issues -</u></b></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Getting nothing reported to newrelic</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><img height="105" src="https://lh5.googleusercontent.com/XRpwXvhge0I2PubWu36f7z3H8lY8mEscIP6w_Qd-2Zi1qF_WjpnyY7XaQAkY5SAvqxlXsdYXT1CdrGp3MzsK2MLo6N1Dg6PWrh9nkYr1yRW8iOzbCjVrt-yJaB9ElHmmdV_CH6MX" style="-webkit-transform: rotate(0.00rad); border: none; transform: rotate(0.00rad);" width="624" /></span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Reason -</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">curl -i -u username:password http://localhost:15672/api/vhosts</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">HTTP/1.1 401 Unauthorized</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Server: MochiWeb/1.1 WebMachine/1.10.0 (never breaks eye contact)</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Date: Fri, 16 Dec 2016 16:56:44 GMT</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Content-Length: 57</span></div>
<br /><span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;">{"error":"not_authorised","reason":"Not management user"}</span><br />
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;">Solution - </span><br />
<span style="background-color: white; color: #333333; font-family: Arial; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;">I had to create another user specifically for the monitoring, with administrator tag and proper permissioning as per the RabbitMQ <a href="https://www.rabbitmq.com/man/rabbitmqctl.1.man.html">documentation</a> </span></div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-27815916780517438802016-06-21T19:40:00.000-07:002016-06-21T19:40:11.927-07:00Django 1.7, 1.8 - queryset.extra is deprecated, how to do group by on datetime with date<div dir="ltr" style="text-align: left;" trbidi="on">
In Django 1.5/1.6 version -<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">signup_count = list(User.objects.filter(</span><br />
<span style="font-family: Courier New, Courier, monospace;"> profile__user_type='learner').order_by(</span><br />
<span style="font-family: Courier New, Courier, monospace;"> '-id').extra({</span><br />
<span style="font-family: Courier New, Courier, monospace;"> 'date_only': "date(date_joined)"}).values(</span><br />
<span style="font-family: Courier New, Courier, monospace;"> 'date_only').annotate(</span><br />
<span style="font-family: Courier New, Courier, monospace;"> signup_count=Count('id'))[:40])</span><br />
<br />
It used to return list with<br />
[{ 'date_only': <date>, 'signup_count': <number> }]</number></date><br />
<br />
Now, as the extra is deprecated in newer version of Django, here the work around to get the same -<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">from django.db.models.expressions import Func</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"># Create custom sql function</span><br />
<span style="font-family: Courier New, Courier, monospace;">class ExtractDateFunction(Func):</span><br />
<span style="font-family: Courier New, Courier, monospace;"></span><br />
<span style="font-family: Courier New, Courier, monospace;"> function = "DATE"</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">signup_signup = list(User.objects.filter(</span><br />
<span style="font-family: Courier New, Courier, monospace;"> profile__user_type='learner').order_by(</span><span style="font-family: "Courier New", Courier, monospace;">'-id')annotate(</span><br />
<span style="font-family: "Courier New", Courier, monospace;">date_only=ExtractDateFunction("date_joined")).values(</span><br />
<span style="font-family: Courier New, Courier, monospace;">'date_only').annotate(</span><br />
<span style="font-family: Courier New, Courier, monospace;">teacher_count=Count('id'))[:40])</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This should give you the same results as before. </span><br />
<br /></div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-6984299351860971642016-06-06T12:33:00.002-07:002016-06-06T12:33:38.944-07:00There is no South database module 'south.db.mysql' for your database - Django<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="p1">
<span class="s1">Django 1.8+</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">Recently I come across this error, while running my Django application </span></div>
<div class="p1">
<span class="s1"><span style="font-family: Courier New, Courier, monospace;">python manage.py runserver</span></span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">There is no South database module 'south.db.mysql' for your database. Please either choose a supported database, check for SOUTH_DATABASE_ADAPTER[S] settings, or remove South from INSTALLED_APPS.</span></div>
<div class="p1">
<br /></div>
<div class="p1">
To fix it, you would try to lookup for south.db.mysql or try to search if you SOUTH_DATABASE_ADAPTERS. But you won't find it in your solution. To fix it you have two choices -</div>
<div class="p1">
<br /></div>
<div class="p1">
1. Manually downgrade to lower Django version i.e.1.6 or so. </div>
<div class="p1">
<span style="background-color: white; color: #242729; font-size: 15px; line-height: 19.5px;"><span style="font-family: Courier New, Courier, monospace;">pip install Django==1.6.10</span></span></div>
<div class="p1">
<br /></div>
<div class="p1">
2. Uninstall South from your environment (virtual environment) and move to built-in migration process. </div>
<div class="p1">
<span style="font-family: Courier New, Courier, monospace;">pip uninstall south</span></div>
<div class="p1">
<br /></div>
<div class="p1">
<br /></div>
<div class="p1">
Good luck!</div>
</div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-4207646435337538722016-01-16T20:31:00.003-08:002016-01-16T20:31:54.076-08:00Search in Django with Haystack using Solr or Elastic Search<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Arial, Helvetica, sans-serif;">Lets say you want to provide search on your Django application. In specific model, or file search on your media files or data files uploaded by users. </span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></span></div>
<span style="font-family: Arial, Helvetica, sans-serif;">Here are tech solution for it -</span><br />
<b style="font-weight: normal;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><a href="http://haystacksearch.org/">HayStack</a> - Modular search for Django</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Arial, Helvetica, sans-serif;">It allows querying on top of any search engine from following - Solr, ElasticSearch, Xapian, Whoosh. </span></span></div>
<b style="font-weight: normal;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Arial, Helvetica, sans-serif;">Solr and ElasticSearch is built on top of powerful search server Apache Lucene. Both are free, and under Apache License 2. </span></span></div>
<b style="font-weight: normal;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Arial, Helvetica, sans-serif;">Interesting presentation on <a href="https://docs.google.com/presentation/d/1oxudl54VLmjPypZ4xMPgUzRJ8-7oWij3S3bN-wPYpGM/present#slide=id.i0">Solr vs ElasticSearch</a></span></span></div>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Arial, Helvetica, sans-serif;"><b>ElasticSearch</b> is distributed, some functions in Solr doesn't not allow distributed execution. Easy cloud support with third party. easy to scale, add/remove nodes. ES is realtime and distributed. </span></span></div>
<b style="font-weight: normal;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Arial, Helvetica, sans-serif;">Solr and ElasticSearch both provides admin page, in ES its called <a href="http://mobz.github.io/elasticsearch-head/">ElasticSearch-Head</a>. ES also provides concept of GateWay, which allows index recovering if the system crash in any case.</span></span></div>
<b style="font-weight: normal;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Arial, Helvetica, sans-serif;">Use ES if - index is big and real time, several indices, multi tenancy requirement, want to save administrative effort and cost.</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Arial, Helvetica, sans-serif;">Don’t use ES if - your company is relatively new, and already using Solr, or no real-time search indexing required, relatively small indices</span></span></div>
<b style="font-weight: normal;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Utility other than ElasticSearch-Head, is <a href="https://github.com/lukas-vlcek/bigdesk">ElasticSearch-bigdesk</a></span><span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> which provides analytics and charts.</span></span></div>
<b style="font-weight: normal;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Arial, Helvetica, sans-serif;"><b>Solr</b> </span></span><span style="font-family: Arial, Helvetica, sans-serif; font-size: 14.6667px; line-height: 1.38; white-space: pre-wrap;">There are some concern when real time index updates and search queries been performed. For plain vanilla search Solr out performs and works much better than ES. </span></div>
<b style="font-weight: normal;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">You can find more comparison <a href="http://blog.socialcast.com/realtime-search-solr-vs-elasticsearch/">here</a>.</span></span></div>
<b style="font-weight: normal;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></b>
<div dir="ltr" style="margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; vertical-align: baseline;"><span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-size: 14.6667px; line-height: 1.38; white-space: pre-wrap;">Solr is older than ElasticSearch, so it got bigger community and help available online. At the same time ElasticSearch was built in order to overcome the scaling limitation of Solr. ES is stable, though Solr is more mature.In terms of </span><span style="font-size: 14.6667px; line-height: 20.24px; white-space: pre-wrap;">scalability</span><span style="font-size: 14.6667px; line-height: 1.38; white-space: pre-wrap;">, ElasticSearch is easy to scale compare to Solr, but with Solr 4.0 that limitation will be gone as per the documentation.</span></span></span></div>
<b style="font-weight: normal;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></b>
<div dir="ltr" style="margin-bottom: 0pt; margin-top: 0pt;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: transparent; vertical-align: baseline;"><span style="font-size: 14.6667px; line-height: 1.38; white-space: pre-wrap;">Sematext provides support for both Solr and ElasticSearch, you can find good overview and </span><span style="font-size: 14.6667px; line-height: 20.24px; white-space: pre-wrap;">comparisons</span><span style="font-size: 14.6667px; line-height: 1.38; white-space: pre-wrap;"> on various categories in this series of </span><a href="http://blog.sematext.com/2012/08/23/solr-vs-elasticsearch-part-1-overview/" style="color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; line-height: 1.38; text-decoration: none; white-space: pre-wrap;">blog post</a><span style="font-size: 14.6667px; line-height: 1.38; white-space: pre-wrap;"> by them. </span></span></span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /><span style="vertical-align: baseline;"><span style="font-size: 14.6667px; white-space: pre-wrap;">and now the competition is joined by Amazon CloudSearch, applications which use AWS for hosting also seems widely using CloudSearch. Here is <a href="http://www.8kmiles.com/amazon-cloudsearch-vs-apache-solr/">comparison</a> between CloudSearch and Solr.</span></span><span style="font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;"> There is no clear winner! Make choice based on requirement of your environment. Try to keep it simple, unless its really required. </span></span></div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-22574251686011275442016-01-13T16:09:00.002-08:002016-01-13T16:09:45.007-08:00Python 32bit or 64bit ?<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: small;">
Recently I moved my application from centOS 5 to centOS 7, which had 64bit python installed. It end up crashing my django application because some of the packages I was using were compiled in 32bit python and they weren't compatible.</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: small;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: small;">
First thing you need to check whether the python you are running is 32 bit or 64 bit. Here is the simple command to check it -</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: small;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: small;">
$ python</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: small;">
Python 2.7.5 (default, Nov 20 2015, 02:00:19) </div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: small;">
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: small;">
Type "help", "copyright", "credits" or "license" for more information.</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: small;">
>>> import struct</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: small;">
>>> print struct.calcsize("P") * 8</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: small;">
64</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: small;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: small;">
That means its 64bit!</div>
</div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-78251801825590757492016-01-08T21:59:00.004-08:002016-01-08T21:59:38.105-08:00Redis server installation on webfaction/ on shared server<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">I come across <a href="http://redis.io/">redis</a> while using <a href="https://github.com/getsentry/sentry">sentry</a>. With the latest version 7.7.4, you need redis to run sentry. </span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Here are the steps to install Redis server on shared server of <a href="https://www.webfaction.com/">webfaction</a> -</span></div>
<b id="docs-internal-guid-d2a580d0-24f0-ae85-8d7b-309f15853e72" style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">First fetch redis installation on home directory (of your account)</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$ wget "http://download.redis.io/releases/redis-3.0.6.tar.gz"</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Extract it and remove the version name from the directory. </span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$ tar -xzf redis-3.0.6.tar.gz </span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$ mv redis-3.0.6 redis</span></div>
<b style="font-weight: normal;">(to keep it clean remove the </b><span style="background-color: #eeeeee; font-family: Consolas; font-size: 14.6667px; line-height: 20.24px; white-space: pre-wrap;">redis-3.0.6.tar.gz)</span><br />
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Run installation</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 11pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$ make</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Run test to verify that installation was correct</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 11pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$ make test</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Now go to webfaction and create custom app, so that we can get port number and we can use it at various places on the configuration. </span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><img height="356px;" src="https://lh4.googleusercontent.com/ISB29yWrburAFQkXQ_G8a8KcrKW25gClyLbIn1zXaPfMK03pGQvRnhZd55leJrODJwposD-qRBWknUOAnGKBe34IAWJSk2EkweLviakJpbByRCr1qbILUx3cYflgBBisk2wstrD7" style="-webkit-transform: rotate(0.00rad); border: none; transform: rotate(0.00rad);" width="624px;" /></span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">It will get you the new port information and creates the directory based on the name you have given inside the webapps directory in your account.</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">As per above, your app name is redis_server and custom port for it - 19957</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Now copy redis.conf from extraction to the webapps.</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 11pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$ cd ~/webapps/redis_server/ </span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 11pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$ cp ~/redis/src/redis-server . </span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 11pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$ cp ~/redis/src/redis-cli .</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 11pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$ cp ~/redis/redis.conf .</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Update three items in the redis.conf file.</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.2; margin-bottom: 17pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">daemonize no</span><span style="background-color: white; color: #222426; font-family: Arial; font-size: 15.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> > </span><span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">daemonize yes</span></div>
<div dir="ltr" style="line-height: 1.2; margin-bottom: 17pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">pidfile /var/run/redis.pid</span><span style="background-color: white; color: #222426; font-family: Arial; font-size: 15.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> > </span><span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">pidfile /home/<account_id>/webapps/redis_server/redis.pid</account_id></span></div>
<div dir="ltr" style="line-height: 1.2; margin-bottom: 11pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">port 6379</span><span style="background-color: white; color: #222426; font-family: Arial; font-size: 15.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> -> </span><span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">port 19957</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Now try to run it manually to verify once. (ideally we want to run it in background)</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">./redis-server redis.conf</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Once it’s running, you can test if its running fine or now by going to cli </span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">./redis-cli -p 19957</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">It should prompt -</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">127.0.0.1:19957></span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Otherwise it will say-</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">not connected ></span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">you can get out of the cli mode by </span><span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Ctl + d</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">You can automate this commands by creating Makefile</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">vi Makefile</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">client cli:</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> ./redis-cli -p 19957</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">start restart:</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> ./redis-server redis.conf</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">stop:</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> cat redis.pid | xargs kill</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">In order to start now, you can use </span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">make start</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">to stop</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">make stop</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">you can manually search and find the redis process</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: #222426; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">ps -u $USER -o pid,command | grep redis</span></div>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">and kill it manually</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Would still prefer the clean way of </span></div>
</div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-33765306953631759372016-01-06T12:58:00.000-08:002016-01-06T12:58:33.098-08:00Sentry - That page number is less than 1 [error]<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="p1">
<span class="s1">While running sentry, when you click on your project, it throws Internal server error with some random code. If you look at the log, it shows something like following. Only thing stands out is "<b>That page number is less than 1</b>" </span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1"> File "/home/User/.virtualenvs/sentry/lib/python2.7/site-packages/sentry-6.4.4-py2.7.egg/sentry/templatetags/sentry_helpers.py", line 217, in paginator</span></div>
<div class="p1">
<span class="s1"> result = paginate_func(request, queryset_or_list, per_page, endless=True)</span></div>
<div class="p1">
<span class="s1"> File "/home/User/.virtualenvs/sentry/lib/python2.7/site-packages/paging/helpers.py", line 24, in paginate</span></div>
<div class="p1">
<span class="s1"> 'paginator': paginator.get_context(page),</span></div>
<div class="p1">
<span class="s1"> File "/home/User/.virtualenvs/sentry/lib/python2.7/site-packages/paging/paginators.py", line 96, in get_context</span></div>
<div class="p1">
<span class="s1"> 'previous_page': paginator.previous_page_number(),</span></div>
<div class="p1">
<span class="s1"> File "/home/User/.virtualenvs/sentry/lib/python2.7/site-packages/Django-1.5.8-py2.7.egg/django/core/paginator.py", line 143, in previous_page_number</span></div>
<div class="p1">
<span class="s1"> return self.paginator.validate_number(self.number - 1)</span></div>
<div class="p1">
<span class="s1"> File "/home/User/.virtualenvs/sentry/lib/python2.7/site-packages/Django-1.5.8-py2.7.egg/django/core/paginator.py", line 30, in validate_number</span></div>
<div class="p1">
<span class="s1"> raise EmptyPage('That page number is less than 1')</span></div>
<br />
<div class="p1">
<span class="s1">EmptyPage: <b>That page number is less than 1</b></span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">This error is because of the django-paging version, you may have version lower than 0.2.5. you need >=0.2.5 </span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">Run the following command -</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">
</span></div>
<div class="p1">
<span class="s1">pip install django-paging==0.2.5</span></div>
<div class="p1">
<br /></div>
<div class="p1">
And restart your sentry server (web). </div>
</div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-50385545934504172902015-12-31T13:04:00.000-08:002015-12-31T13:04:36.929-08:00ReferenceError: Promise is not defined on gulp build<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="p1">
<span class="s1">While going thru getting started guide of polymer starter kit, I run into following issue -</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">> gulp</span></div>
<div class="p2">
<span class="s2">[</span><span class="s3">15:12:04</span><span class="s2">] Using gulpfile </span><span class="s1">~/Apps/js/polymer-playground/example/polymer-starter-kit-1.2.1/gulpfile.js</span></div>
<div class="p1">
<span class="s1">[</span><span class="s3">15:12:04</span><span class="s1">] Starting '</span><span class="s4">clean</span><span class="s1">'...</span></div>
<div class="p1">
<span class="s1">[</span><span class="s3">15:12:04</span><span class="s1">] Finished '</span><span class="s4">clean</span><span class="s1">' after </span><span class="s5">18 ms</span></div>
<div class="p1">
<span class="s1">[</span><span class="s3">15:12:04</span><span class="s1">] Starting '</span><span class="s4">default</span><span class="s1">'...</span></div>
<div class="p1">
<span class="s1">[</span><span class="s3">15:12:04</span><span class="s1">] Starting '</span><span class="s4">copy</span><span class="s1">'...</span></div>
<div class="p1">
<span class="s1">[</span><span class="s3">15:12:04</span><span class="s1">] Starting '</span><span class="s4">styles</span><span class="s1">'...</span></div>
<div class="p3">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1">/Users/UserName/Apps/js/polymer-playground/example/polymer-starter-kit-1.2.1/node_modules/gulp-autoprefixer/node_modules/postcss/lib/lazy-result.js:157</span></div>
<div class="p1">
<span class="s1"> this.processing = new Promise(function (resolve, reject) {</span></div>
<div class="p1">
<span class="s1"> ^</span></div>
<div class="p1">
<span class="s1">ReferenceError: Promise is not defined</span></div>
<br />
<div class="p1">
<span class="s1"> at LazyResult.async (/Users/UserName/Apps/js/polymer-playground/example/polymer-starter-kit-1.2.1/node_modules/gulp-autoprefixer/node_modules/postcss/lib/lazy-result.js:157:31)</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">The issue is my node version, it needs to be 0.12.5 (it was 0.10.3)</span></div>
<div class="p1">
<br /></div>
<div class="p1">
Here are the steps to upgrade -</div>
<div class="p1">
</div>
<div class="p1">
<span class="s1">$ sudo npm cache clean -f</span></div>
<div class="p1">
<span class="s1">
</span></div>
<div class="p1">
<span class="s1">$ sudo npm install -g n</span></div>
<div class="p1">
<span class="s1">$ node -v</span></div>
<div class="p1">
<span class="s1">
</span></div>
<div class="p1">
<span class="s1">v0.10.35</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">It still says 0.10.35</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">Here is the way to switch between versions -</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
$ sudo n stable</div>
<div class="p1">
</div>
<div class="p1">
<span class="s1">$ node -v</span></div>
<div class="p1">
<span class="s1">v5.2.0</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">means Now we can move to 0.12.5 in easy steps -</span></div>
<div class="p1">
<span class="s1">
</span></div>
<div class="p1">
<span class="s1">$ sudo n 0.12.5</span></div>
<div class="p1">
<span class="s1">$ node -v</span></div>
<div class="p1">
<span class="s1">0.12.5</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">Now running gulp build works fine!</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
</div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-54052649303660053402015-12-28T19:51:00.001-08:002015-12-28T19:51:54.001-08:00pip freeze - unknown revision or path not in the working tre<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="p1">
<span class="s1">While trying to get the list of the current package using pip freeze, it throws following error -</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">> pip freeze</span></div>
<div class="p1">
<span class="s1">Complete output from command /usr/bin/git rev-parse (detachedfrom0af02a9):</span></div>
<div class="p1">
<span class="s1">fatal: ambiguous argument '(detachedfrom0af02a9)': unknown revision or path not in the working tree.</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1">Use '--' to separate paths from revisions, like this:</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1">'git <command></command> [<revision>...] -- [<file>...]'</file></revision></span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1">(detachedfrom0af02a9)</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1">----------------------------------------</span></div>
<div class="p1">
<span class="s1">Command /usr/bin/git rev-parse (detachedfrom0af02a9) failed with error code 128</span></div>
<br />
<div class="p1">
<span class="s1">Storing complete log in /home/youraccount/.pip/pip.log</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">It's issue with the outdated pip package. To fix the issue -</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">You can upgrade it with following command -</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">
</span></div>
<div class="p1">
<span class="s1">pip install --upgrade pip</span></div>
<div class="p1">
<br /></div>
<div class="p1">
It should fix the issue.</div>
</div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-36916473265979170502015-12-13T18:40:00.002-08:002015-12-13T18:40:37.921-08:00GO and bee<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">
Get started with Go and Bee framework</span></div>
<b id="docs-internal-guid-993d8925-9e5b-f16b-0281-4f108459902f" style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">brew install go</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">set following in .bash_profile</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">export PATH=$PATH:/usr/local/opt/go/libexec/bin</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">export GOPATH=/Users/<username>/goapp</username></span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">(Instead of username, use path to your home directory)</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">With this you can access go on command prompt, and when you install bee packages it automatically go to go path you have set.</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$ go get github.com/astaxie/beego</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$ go get github.com/beego/bee</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Install sample file to verify its working</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$ cd $GOPATH/src</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$ bee new hello</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$ cd hello</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$ bee run</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">In case you want to run the application on different port, open app.conf and update the parameters. It's self-explanatory. </span></div>
<br /><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">You will be able to see the welcome screen. </span></div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-44100758406321430582015-12-07T20:44:00.001-08:002015-12-07T20:44:55.785-08:00Sentry Installation in local<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="font-family: Arial; font-size: 14.6667px; line-height: 1.38; white-space: pre-wrap;"><a href="https://github.com/getsentry/sentry">Sentry</a> is error logging, aggregation and tracking package. (for both server side, and client side)</span></div>
<b id="docs-internal-guid-7adf84a6-7fe1-b9ff-bcf8-c67347eb663e" style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">mkvirtualenv sentry</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">workon sentry</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">pip install sentry --upgrade</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">sentry init</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: #999999; font-family: Arial; font-size: 14.666666666666666px; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">It will ask for creating conf file in your parent user dir. e.g. /Users/<local user="">/.sentry/sentry.conf.py</local></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: #999999; font-family: Arial; font-size: 14.666666666666666px; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">vi /home/<span style="font-size: 14.6667px; line-height: 20.24px;"><local user=""></local></span>/.sentry/sentry.conf.py > you can review the file</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Set </span><span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">SENTRY_ADMIN_EMAIL </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">and </span><span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">SENTRY_URL_PREFIX</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">SENTRY_ADMIN_EMAIL : ‘</span><span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">your@email.com</span><span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">’</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">SENTRY_URL_PREFIX: ‘http://127.0.0.1:9000</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">’</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">easy_install -UZ sentry[postgres]</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: #999999; font-family: Arial; font-size: 14.666666666666666px; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Creates postgres db for sentry</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">sentry --config=/home/<local user="">/.sentry/sentry.conf.py upgrade</local></span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">you may run into issue with redis connectivity - </span><span style="background-color: transparent; color: red; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">127.0.0.1:6379. Connection refused</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Check if redis is running -</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$ </span><span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">redis-cli</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Could not connect to Redis at 127.0.0.1:6379: Connection refused</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">not connected></span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">That means redis is not running, open another terminal and run following command -</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$ </span><span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">redis-server</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Now if you run the previous command again -</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$ </span><span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">redis-cli</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">redis 127.0.0.1:6379></span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Now try to run the upgrade command -</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">It fails with following error -</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: red; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Incompatible library version: etree.so requires version 12.0.0 or later, but libxml2.2.dylib provides version 10.0.0</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">the issue is with libxml2, I resolved using </span><a href="http://stackoverflow.com/questions/23172384/lxml-runtime-error-reason-incompatible-library-version-etree-so-requires-vers" style="text-decoration: none;"><span style="background-color: transparent; color: #1155cc; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;">this</span></a><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> stack overflow thread - </span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">brew install libxml2 </span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">brew install libxslt </span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">brew link libxml2 --force </span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">brew link libxslt --force</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">It will create all required tables, default user (select it as super user)</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Now start sentry -</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #eeeeee; color: black; font-family: Consolas; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">sentry start</span></div>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Go to </span><a href="http://127.0.0.1:9000/" style="text-decoration: none;"><span style="background-color: transparent; color: #1155cc; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;">http://127.0.0.1:9000/</span></a><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> to access the local sentry. Get configuration and setup in your project to see the errors get logged on this local sentry instance. </span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Happy logging!</span></div>
</div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-92022174460554521822015-05-17T20:18:00.001-07:002015-05-17T20:18:29.812-07:00xcode intellisense/autocomplete stopped working - How to bring it back?<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
While doing swift code in Xcode the intenseness suddenly stopped working. How do I bring it back?<br />
<br />
Here are few things you can try -<br />
<br />
<br />
<ul style="text-align: left;">
<li>Restart the Xcode - you may get lucky and it may start working</li>
<li>Next option - Start with Command + Shift + Key and clean the project</li>
<li>If its still not working, now we are going little detail, go to /Users/Library/Developer/Xcode/DerivedData</li>
<ul>
<li>Find your project directory for which its broken, delete the content of the folder</li>
<li>Other way to do the same is from Xcode, go to Windows > Organize > Delete the Derived data</li>
</ul>
<li>Delete the ModuleCache folder content from the
<div class="p1">
<span class="s1">/Users/Library/Developer/Xcode/DerivedData and restart the Xcode, it should come up fine.</span></div>
</li>
</ul>
<div>
Good luck with the fix, let me know if it works or if I should add any additional technique to handle this.</div>
<br />
</div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-66900958003406602592015-05-16T20:51:00.001-07:002015-05-16T20:51:19.125-07:00payment processing gateways and facilitator startups & business in India<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
Lately there has been buzz on the payment processor companies around the world, and so there so many companies trying to break into the market in India too. Its huge market, though not much regulated and still people rely on cash for most of their transactions/ at least small transactions. </div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
Here are some of the companies in the space. I'll try to update the list periodically.</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
Square type of -</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="https://www.ezetap.com/" style="color: #1155cc;" target="_blank">ezetap</a> - dongle</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="https://mobiswipe.in/" style="color: #1155cc;" target="_blank">mobiswipe</a> - dongle</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="http://www.prizmpayments.com/" style="color: #1155cc;" target="_blank">prizmpayments</a> - <span class="il">payment</span> gateway, ATM</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="https://www.mosambee.in/sfn" style="color: #1155cc;" target="_blank">mosambee</a> - dongle (in UAE as well)</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="https://aasaanpay.com/" style="color: #1155cc;" target="_blank">aasaanpay</a> - dongle</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="http://www.paypos.com/" style="color: #1155cc;" target="_blank">paypos</a> - dongle</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="http://www.mswipetech.com/Index.htm" style="color: #1155cc;" target="_blank">mswipe</a>- dongle</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="http://www.swiffpay.com/" style="color: #1155cc;" target="_blank">swiftpay</a> - dongle</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<span class="il">Payment</span> Gateways-</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="https://www.payu.in/index" style="color: #1155cc;" target="_blank">payU</a> - <span class="il">payment</span> gateway, popular</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="http://www.ebs.in/en/" style="color: #1155cc;" target="_blank">ebs</a> - <span class="il">payment</span> gateway, Axis bank collaboration, popular</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="http://www.ccavenue.com/ccavenue_index.jsp" style="color: #1155cc;" target="_blank">CCAvenue</a> - <span class="il">payment</span> gateway, this one is most successful and most expensive</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="https://www.zaakpay.com/" style="color: #1155cc;" target="_blank">ZaakPay</a> - <span class="il">payment</span> gateway</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="http://www.direcpay.com/direcpay/home.jsp" style="color: #1155cc;" target="_blank">DirectPay</a> - <span class="il">payment</span> gateway, times group <span class="il">payment</span> service</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="https://www.payzippy.com/" style="color: #1155cc;" target="_blank">payzippy</a> - <span class="il">payment</span> gateway, getting popular because of flipcart</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="http://www.citruspay.com/" style="color: #1155cc;" target="_blank">citrus</a> - <span class="il">payment</span> gateway</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="http://www.atomtech.in/" style="color: #1155cc;" target="_blank">atom</a> - <span class="il">payment</span> gateway</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="https://www.payumoney.com/" style="color: #1155cc;" target="_blank">payumoney</a> - <span class="il">payment</span> gateway</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="http://www.transecute.com/" style="color: #1155cc;" target="_blank">transecute</a> - <span class="il">payment</span> gateway</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="http://www.epaymentsglobal.com/" style="color: #1155cc;" target="_blank">epaymentglobal</a> - <span class="il">payment</span> gateway</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="http://fethr.com/" style="color: #1155cc;" target="_blank">fethr</a> - new one</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="http://www.billdesk.com/" style="color: #1155cc;" target="_blank">billdesk</a> - not sure why this one is popular</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
There are few other services, but can't really understand their stand or competitive advantage over others.</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="http://epay.icegate.gov.in/epayment/locationAction" style="color: #1155cc;" target="_blank">icegate</a></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="https://gepg.nic.in/" style="color: #1155cc;" target="_blank">government of india e-<span class="il">payment</span></a></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="http://www.axisbank.com/business-banking/merchant-solutions/internet-payment-gateway.aspx" style="color: #1155cc;" target="_blank">axis bank</a></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<a href="https://www.emvantage.com/" style="color: #1155cc;" target="_blank">emvantage</a></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
The issues you can smell from the online comments and threads -</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
Dongle - </div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
1. Merchants don't have devices (cellphones which can accept the cash).</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
2. People carrying cash, also some merchant prefer cash.</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
3. Door to door service while setting it up and spread knowledge of the advantages, though if its executed sophistically, it sure has a good future. At the same time it requires proactive merchants who are willing to do technology way, which anyway going to be future. </div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
For the <span class="il">payment</span> gateways </div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
- The integration takes at least 3 weeks, which is really bad. Unlike stripe its mostly a day or two.</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
- On top of none of them are <a href="http://www.quora.com/Payment-Gateways/What-is-the-difference-between-PayU-and-PayUPaisa" style="color: #1155cc;" target="_blank">transparent</a> in terms of the charges. Lot of different charges and for someone to setup online store with<span class="il">payment</span> gateway is really tough. Thats why people rely on <a href="http://www.shopify.com/payment-gateways/india" style="color: #1155cc;" target="_blank">Shopify</a>, which makes it little bit easy. even after integrating payU, its such an awful service you can read in the <a href="http://ecommerce.shopify.com/c/payments-shipping-fulfilment/t/payment-gateway-for-indian-websites-131005" style="color: #1155cc;" target="_blank">comments</a>. </div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
- Here is some <a href="http://www.nextbigwhat.com/comparison-payment-gateways-in-india-297/" style="color: #1155cc;" target="_blank">comparison</a> between leading <span class="il">payment</span> gateways, and some <a href="http://techaloo.com/comparison-of-payment-gateways-in-india/" style="color: #1155cc;" target="_blank">more</a> (Its little older so some already been demised).</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
- Also banks like ICICI, HDFC and AXIS have their own gateways.</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;">
- The most common complain is none of them are responsive, if anything happens you cant reach the support and sometimes for months. </div>
<div>
<br /></div>
</div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-8046474320816228082015-05-16T19:31:00.002-07:002015-05-16T19:31:16.902-07:00Keyboard stopped working in xcode simulator<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Arial, Helvetica, sans-serif;">While doing some first time coding on xcode first time I run into an issue where suddenly my keyboard stopped working when select of text box. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<b><span style="font-family: Arial, Helvetica, sans-serif;">Why it happened?</span></b><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Because first time when the textbox opened, you might have clicked on escape and what it will do is it connects the simulator keyboard to your hardware keyboard instead of simulator keyboard.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<b><span style="font-family: Arial, Helvetica, sans-serif;">How to enable again?</span></b><br />
<span style="font-family: Arial, Helvetica, sans-serif;">For your simulator follow below steps:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">iOS Simulator > Hardware > Keyboard</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">Uncheck "Connect Hardware Keyboard"</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">It will disconnect the hardware keyboard connection for the simulator. </span></div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-69173549279610244502014-12-28T14:34:00.000-08:002014-12-28T14:34:18.694-08:00Convert .dta file to .csv file<div dir="ltr" style="text-align: left;" trbidi="on">
.dta is stata data file format, often you want to see the content with other more known tools like google spreadsheet or excel or any other open data format and you need to convert the file to csv format. Follow below steps to quick easy conversion.<br />
<br />
Download python pandas if you already don't have it installed.<br />
<br />
<br />
<div class="p1">
<span class="s1">pip install pandas</span></div>
<div class="p1">
<br /></div>
Navigate to the folder where you have stored .dta file and follow below set of instruction to get csv out of it -<div>
<br /></div>
<div>
<div class="p1">
<span class="s1">>>> import pandas as pd</span></div>
<div class="p1">
<span class="s1">
</span></div>
<div class="p1">
<span class="s1">>>> data = pd.io.stata.read_stata('sample.dta')</span></div>
<div class="p1">
<span class="s1">
</span></div>
<div class="p1">
<span class="s1">>>> data.to_csv('changed_to_csv.csv')</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">And you will get quick csv conversion of the dta file.</span></div>
</div>
</div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0tag:blogger.com,1999:blog-4123685553441531763.post-28931618895283076312014-06-17T21:46:00.001-07:002014-06-18T07:32:18.514-07:00Setup New Relic with Webfaction Django App (Python setup)<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div dir="ltr" style="margin-bottom: 0pt; margin-top: 0pt;">
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17.25px; white-space: pre-wrap;">New Relic is awesome Application Performance management tool. You can setup your application's health check in few easy steps -</span></span></div>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Create a free account with <a href="http://newrelic.com/">New Relic</a>. Here, below are the steps to setup your app's performance management on New Relic Dashboard :</span></div>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">- Get the licence key from newrelic</span></div>
<b id="docs-internal-guid-1e6916d2-ad43-0bc2-b85e-b19b707c2232" style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">- install package on your server - </span><span style="background-color: #f3f3f3; color: #444444; font-family: 'Courier New'; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">pip install newrelic</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">- generate config file - </span><span style="background-color: #f3f3f3; color: #444444; font-family: 'Courier New'; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">newrelic-admin generate-config <licence_key> newrelic.ini</licence_key></span></div>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">(It should generate newrelic.ini file)</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">- Add following lines in to <appname>.wsgi file (provide the full path of the newrelic.ini)</appname></span></div>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #f3f3f3; color: #444444; font-family: 'Courier New'; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">import newrelic.agent</span></div>
<span style="background-color: #f3f3f3; color: #444444; font-family: 'Courier New'; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;">newrelic.agent.initialize('/path/newrelic.ini')</span><br />
<br />
- Restart the application<br />
<div>
<br /></div>
<div>
Within few minutes the you should be able to see the dashboard with different metrics. Also setup the web url of your application for the ping checker. In case of any issue with it, you will get real time notification. </div>
<div>
<br /></div>
<div>
<br /></div>
<div>
There are other tools like <a href="https://www.datadoghq.com/">DataDog</a> also used by so many companies. Both allows setup of different hosts and apps health check setup. I am also planning to setup celery and solr in new relic dashboard. I'll add setup steps for those as and when its done.</div>
</div>
Jhttp://www.blogger.com/profile/16243232631883704631noreply@blogger.com0