Error 

Archive for June, 2007

Automated Project Creation

Posted June 29, 2007 at 05:06pm in Programming

Here is the script I mentioned the other day. For the most part this is my first Ruby script. I have done a few little tests to see how some things work but nothing more than 5 lines. For that reason please don’t be too harsh if I did something incorrect, but I would like some input.

Basically if you have this script named ‘project.rb’ you would enter:

project testproject "Test Project" htdigest

What that is doing is creating a repository called ‘testproject’ and a trac environment called ‘testproject’ in the directory you specify at the top of the script. It will set the Trac project name to ‘Test Project’ and if the htdigest argument is present it will add the users in the script to the HTDigest file you are using for trac. This script will add the users you specify to the trac environment along with the permissions you think they should have. It will also add those users to your repository passwd file and alter your svnserve.conf file.

One thing it is not doing is altering the trac.ini file. I debate implementing it, and I will need to look into the ways you process INI files in Ruby before I do.

I must also note that with this configuration I am using one virtual host and location for trac environments in Apache. Since this is my local stuff I don’t have a lot of users to be accessing and they will not be changing much from project to project. Below is a screenshot of how my project list looks using the index.tmpl you can download here. You can also download the RB file for this script from here. Also for some reason the highlighting is all funky, but it is still readable.

  1. #!/usr/bin/env ruby
  2. #
  3. # Usage
  4. #
  5. # script <dir> <project name> <htdigest>
  6. #
  7. # Example:
  8. # —————————
  9. # script test "Test Project" htdigest
  10. #
  11. #       - This will create a directory named test in both
  12. #         your repository and trac directories.  The htdigest
  13. #         parameter tells it to write to your htdigest file.
  14. #
  15.  
  16. require ‘digest/md5′
  17. user = Hash.new
  18. perm = Hash.new
  19.  
  20. #
  21. # Changes these locations to fit your environment
  22. #
  23. repo_loc = ‘C:/DEV/repo/’                   # Directory for the SVN Repo
  24. trac_loc = ‘C:/DEV/trac/’                   # Directory for the Trac Project
  25. svn_loc = ‘E:/Subversion/bin/’              # Subversion Bin Directory
  26. py_loc = ‘C:/Programs/Python24/’            # Python Directory
  27. htd_loc = ‘D:/DEV/trac/htdigest’            # HTDigest File Location
  28. tmpl_loc = py_loc + ’share/trac/templates’  # Template Directory
  29.  
  30. #
  31. # Repository Configuration
  32. #
  33. conf = <<eof
  34. [general]
  35. anon-access = none
  36. auth-access = write
  37. password-db = passwd
  38. # authz-db = authz
  39. # realm = My First Repository
  40. EOF
  41.  
  42. #
  43. # Trac and Apache users and permissions
  44. #
  45. user[‘manis’] = ‘test’                      # Key is username, value is password
  46. perm[‘manis’] = ‘TRAC_ADMIN’                # Permission in Trac for user
  47.  
  48. #
  49. # In most cases these will not need to be changed
  50. #
  51. realm = ‘trac’                              # Realm for HTDigest
  52. tracdb = ’sqlite:db/trac.db’                # Trac Database Location
  53. repostype = ’svn’                           # Type of Repository for Trac
  54. x_py = py_loc + ‘python ‘                   # Python Executable
  55. x_svn = svn_loc + ’svnadmin create ‘        # Subversion admin + create command
  56. x_trac = py_loc + ‘Scripts/trac-admin ‘     # Trac Admin script
  57. initstring =                              # Initializing (Leave Empty)
  58. htdigest =                                # Initializing (Leave Empty)
  59. passwd = "[users]\n"                        # Initializing (Leave Empty)
  60.  
  61. #
  62. # User Input
  63. #
  64. projpath = ARGV[0]                          # Name of Directory for Trac/SVN
  65. projname = ARGV[1]                          # Project Name for Trac
  66.  
  67. #
  68. # Build Paths, Commands & Trac Environment Initialization String
  69. #
  70. repospath = repo_loc + projpath
  71. tracspath = trac_loc + projpath
  72. templatepath = tmpl_loc
  73. initstring += ‘"’ + projname + ‘"’ + ‘ ‘
  74. initstring += ‘"’ + tracdb + ‘"’ + ‘ ‘
  75. initstring += ‘"’ + repostype + ‘"’ + ‘ ‘
  76. initstring += ‘"’ + repospath + ‘"’ + ‘ ‘
  77. initstring += ‘"’ + templatepath + ‘"’
  78. svn_x = x_svn + repospath
  79. trac_x = x_py + x_trac + tracspath + ‘ initenv ‘ + initstring
  80.  
  81. #
  82. # Execute Commands
  83. #
  84. # This block will check if the svn or trac location already exists and cancel
  85. # if it does.  After executing each command it will loop through the user hash
  86. # and add each user with linked permissions to the trac environment.  If you
  87. # included the parameter ‘htdigest’ after the project name the string created
  88. # during the loop through users will add the new users to the HTDigest file you
  89. # specified above.
  90. #
  91. if (File::exists?(repospath) || File::exists?(tracspath))
  92.     puts ‘Project Exists’
  93. else
  94.     svnb = system(svn_x + ‘ > project.log’)
  95.     tracb = system(trac_x + ‘ > project.log’)
  96.     if svnb && tracb
  97.         puts "Repository Created"
  98.         puts "Trac Environment Created"
  99.         user.each_pair do |k1, v1|
  100.             system(x_py + x_trac + tracspath + ‘ permission add ‘ + k1 + ‘ ‘ + perm[k1].to_s)
  101.             htdigest += k1 + ‘:’ + realm + ‘:’ + Digest::MD5.new.hexdigest(k1 + ‘:’ + realm + ‘:’ + v1) + "\n"
  102.             passwd += k1 + ‘ = ‘ + v1
  103.         end
  104.         if (ARGV[2] && ARGV[2] == ‘htdigest’)
  105.             open(htd_loc, "a") { |f| f.puts htdigest }
  106.         end
  107.         open(repospath+‘/conf/passwd’, "w") { |f| f.puts passwd }
  108.         open(repospath+‘/conf/svnserve.conf’, "w") { |f| f.puts conf }
  109.     else
  110.         puts "An Error Occurred"
  111.     end
  112. end

Here is my apache config for Trac

Apache [Show Plain Code]:
  1. <virtualHost 10.0.10.22>
  2.   SetHandler mod_python
  3.   PythonHandler trac.web.modpython_frontend
  4.   PythonOption TracEnvParentDir D:/DEV/trac/
  5.   PythonOption TracUriRoot /
  6.         PythonOption TracEnvIndexTemplate D:/DEV/trac/index.tmpl
  7.         ServerName trac.myserver.com
  8.         ErrorLog D:/DEV/logs/apache.trac.errors.log
  9.         CustomLog D:/DEV/logs/apache.trac.referer.log referer
  10.         CustomLog D:/DEV/logs/apache.trac.agent.log agent
  11.         CustomLog D:/DEV/logs/apache.trac.access.log combinedio
  12.         CustomLog D:/DEV/logs/apache.trac.deflate.log deflate
  13.         <locationMatch "/[^/]+/login">
  14.           AllowOverride All
  15.           AuthType Digest
  16.           AuthName "trac"
  17.           AuthDigestFile "D:/DEV/trac/htdigest"
  18.           Require valid-user
  19.         </locationMatch>
  20. </virtualHost>

Trac and Subversion

Posted June 28, 2007 at 03:06am in Computers, Programming

While looking through the Wordpress repository I noticed in Trac that there was a link to a ticket and it was crossed out. After poking around I found that if you have a ticket in trac, lets say #822, when you commit to subversion with a log entry containing #822 it will link to that ticket if it exists. So you can say “Security flaw removed, fixes #822″ and it will automatically link the text #822 in trac to the ticket and when that ticket is closed the text will have a text-decoration style of line-through.

I am finishing up a script that will help me with my project creation. It will setup both the subversion repository and trac project along with setup permissions and configuration. I will post it when I am finished since it will probably help others out as well. I am running a regular expression in Apache for the location of trac projects and one htdigest file so those are not being touched in any way.

Consultant…. is it a bad word?

Posted June 25, 2007 at 08:06pm in Business

On LinkedIn Answers there was a question looking for an alternative word to use for Consultant. I too have wondered this, because I can see how the word “Consultant” can spell out Unemployed and it is just an easy way out of the conversation. When I was working in the mortgage industry I was a loan officer, loan consultant, senior loan officer, etc, but never just a consultant. I am now, by the nature of my work, a consultant even though in a lot of ways I do the same as in California, just a different industry.

When I saw the question I thought back to this weekend, someone asked me what I was doing now and I said I was working as a consultant after I moved back from California. People asked where in California, but not what I was consulting on. I think I might go with “Technology Consultant” as my title, it brings a little more shape to the word consultant and then they are more likely to ask what type of technology. Here is a good quote from LinkedIn.

I understand exactly what you’re saying. People in the technical and production domains seem to be the most likely to have the negative connotations of the word ‘consultant’ jump into their mind whenever they hear the word. Unfortunately, there does not seem to be any other word that could replace this term, though there is a crying need for terminology that could differentiate between the different types of consultants.

Consultants do perform a very essential function. I’ll try to explain this through an example: To learn a form of exercise - in ascending order of how much money you would spend - we could read a book, watch a video, go to the neighborhood gym, or hire a personal trainer. The personal trainer, being the most expensive, would also be the most effective.

In my opinion, hiring a consultant is the equivalent of hiring a personal trainer, as only this option - provided you’ve selected the right consultant - can provide a solution perfectly tailored to your needs!

- Vikas Dhawan

I agree with that. When I was in the gym everyday I did a lot of research to get a good program for myself, but with all the information out there it can be difficult. I did a decent job and there was benefit in what I learned for the future, but my most effective choice would have been to hire someone that has spent years studying and following what is going on in their field.

The same applies for what I do, sure you can learn how to do everything I know how to do, but I have spent years working with various operating systems, thousands of software applications, a dozen or so programming languages, and just the general expertise you pick up through time. You could also hire at company @ $80/hr, but you can hire me to do the same job for $50/hr.

The word freelancer was also brought up, but the definitions linked it to someone trying to fill gaps, not someone who specializes in working on projects under contract.

What do you call yourself? How do you react when someone says they are a consultant? What would you rather hear come out of their mouth as a job title for consulting? Just a few questions I have.

Myspace DIV Overlay update

Posted June 21, 2007 at 09:06pm in Design

I was sick of my old Myspace profile so I did an update tonight. It is very simple, but it works. Visit my profile, but don’t expect me to start using Myspace.

My Dog Bit me, please give advice

Posted June 21, 2007 at 07:06pm in General

I was laying on the bed with my dog sorta playing around and had his leg and pretended like I was chewing on it. He is usually playful, but this time he bit my head and when I got up I drew back out of reaction and he snarled at me and growled. I will admit in the past I have hit him, not the best solution, but it was only a few times and I don’t do it anymore. Anyway was he just playing you think or was he being mean? He is a sweet dog, but sometimes I don’t know what if he is playing or not.

Some people have said when a dog bites you it must be put down or it will do it again, but I can’t do that and won’t do that. He has never done that to anyone else so I am thinking it might have been he thought I was trying to hurt him or he was just playing. He is trained somewhat, but not what he should be so any advice on training a dog 2 years old or any advice on this subject at all is appreciated.