Posts

Showing posts from 2015

Maya and Mac os using different version of SVN

While writing some tools for Maya to perform SVN operations, I found that they were erring out. To investigate the problem I ran a simple test in Mac Terminal and Maya. Mac terminal : $  svn --version Output :  svn, version 1.8.13 (r1667537) Maya  : import subprocess command = "svn --version" process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE,           stderr=subprocess.PIPE, universal_newlines=True) out, err = process.communicate() print out,err Output :  svn, version 1.7.10 (r1665045) Problem : Clearly my Mac Os and Maya were using different SVN. On executing command: "which svn" Terminal gave =  /usr/bin/svn Maya gave      = usr/local/bin/svn After spending allot of time, I was not able to figure out how to point maya to use usr/local/bin/softwares. I tried modifying - /etc/paths file (which is $PATH), - /Users/username/.bash_profile My Solution: 1. Install svn using brew : $brew install svn When instal

Calling an external command in Python

Here's a summary of the ways to call external programs and the advantages and disadvantages of each: os.system("some_command with args")  passes the command and arguments to your system's shell. This is nice because you can actually run multiple commands at once in this manner and set up pipes and input/output redirection. For example, os.system("some_command < input_file | another_command > output_file") However, while this is convenient, you have to manually handle the escaping of shell characters such as spaces, etc. On the other hand, this also lets you run commands which are simply shell commands and not actually external programs. see documentation stream = os.popen("some_command with args")  will do the same thing as  os.system  except that it gives you a file-like object that you can use to access standard input/output for that process. There are 3 other variants of popen that all handle the i/o slightly differently. If you pa

Robomongo and MongoDB - initial setup on Mac

Image
1. Install MongoDB : Download tgz or zip file from MongoDB website   Extract tgz or zip file in home directory eg : /Users/userName/mongodb_x86_64-3.0.0 Add path of mongoDB directory in PATH 2. Run MongoDB server : Create a directory for primary DB path. /Users/userName/mongodb_x86_64-3.0.0/data/db Run Command /Users/userName/mongodb_x86_64-3.0.0/bin/mongod --dbpath /Users/userName/mongodb_x86_64-3.0.0/data/db  --bind_ip 0.0.0.0 -v 3. Install RoboMongo : Download RoboMongo from http://robomongo.org/ Drop downloaded/extracted folder in Applications folder (/Applications) 4. Run RoboMongo and Connect with MongoDB : 5. Create Example Database in RoboMongo : Step 1 : Create Database Step 2 : Create Collection ( Collection of Documents/Tables ) Step 3 : Create Document/Table  Step 4 : Insert data in Document Query Test in Python ( using pymongo) import pymongo # Connecting with server client = pymongo.MongoClient('

Dictionary vs KeyValuePair vs Struct - C#

Dictionary :  //   Declare   Dictionary and assign value Dictionary < string ,  object >  parameter  =  new   Dictionary < string ,  object >(); parameter [ " View " ] =  viewComp ; parameter [ " Play " ] =  true ; FunctionName( parameter ); //   Use   Dictionary private   void   FunctionName ( object   parameter ) {      Dictionary < string ,  object >  dict  = ( Dictionary < string ,  object >) parameter ;      GameObject   viewComp  = ( GameObject ) dict  [ " View " ];      bool   play  = ( bool ) dict [ " Play " ];      UseValuesInFunction ( viewComp ,  play ); } KeyValuePair : KeyValuePair < GameObject ,  bool >  parameter  =  new   KeyValuePair < GameObject ,  bool >( viewComp ,  true ); FunctionName( parameter ); //   Use   KeyValuePair                    private   void   FunctionName ( object   parameter ) {      KeyValuePair < GameObject ,  bool >  param  = ( KeyValuePair < Gam