I find at work I do a lot of command line hackery, and Perforce’s output is a touch spamtastic. As such, I whipped up a quick script in python that converts most of the output to svn style output. Hope this helps someone.
# Author: Eddie Parker
# URL: http://kickingdragon.com
# Usage: p4 [command] | python perforce_to_svn.py
# i.e. p4 sync | python perforce_to_svn.py
import sys
import re
import os
r = re.compile('^.*- (?P<COMMAND>.+) (?P<PATH>[a-zA-Z]:\\\.*)')
cwd = os.getcwd().lower()
if cwd.startswith('/cygdrive/'):
# Make it non cygwin.
cwd = cwd.replace('/cygdrive/','')
cwd = cwd[0] + ':' + cwd[1:]
cwd = cwd.replace('/', '\\')
if cwd[-1] != '\\':
cwd += '\\'
for line in sys.stdin:
m = r.match(line)
if m != None:
d = m.groupdict()
characterCode = d['COMMAND'][0].upper()
path = d['PATH']
if path.lower().startswith(cwd):
path = path[len(cwd):]
print ' %s %s'%(characterCode, path)
else:
sys.stdout.write(line)
Somewhere in the last few server updates, my SSL had broken for KickingDragon, and I couldn’t for the life of me figure out what was going wrong from the configuration files.
I’ve been eyeing LightTPD for a while now, and figured this would be worth a shot. As it turned out, it only took an hour or so and a bit of monkeying with rewrite rules to get everything built and working.
The hardest part for me was rewriting the rewrite rules appropriately so I could maintain my pretty URL’s.
I thought I’d share in case anyone else is having problems. I’ve added liberal comments to help understand things better:
- # All my vhosts share the same ssl data.
- $SERVER["socket"] == ":443" {
- ssl.engine = "enable"
- ssl.pemfile = "/etc/ssl/lighttpd/server.pem"
- }
- # KickingDragon hosts itself as well as
- # my sister's art blog at http://kickingdragon.com/karen
- # I need to handle# rules for rewriting both wordpress blogs properly.
- $HTTP["host"] == "kickingdragon.com" {
- # Karen's stuff sits at karen/wordpress in the file system, but the URL's
- # are http://kickingdragon.com/karen. Rewrite appropriately.
- # Use rewrite-once so multiple rules don't chain.
- url.rewrite-once = (
- # Anything with wp- prefix gets forwarded on
- "^/karen/(wp-.*)$" => "/karen/wordpress/$1",
- # xmlrpc is a literal file - don't go forwarding it to index.
- "^/karen/xmlrpc.php$" => "/karen/wordpress/xmlrpc.php",
- # Wordpress uses index.php as the entry point for code that 'reads' the URL and
- # decide where to go from their. Terminal rule for /karen items.
- "^/karen(/.*)?$" => "/karen/wordpress/index.php/$1",
- # Kicking Dragon's
- # Same as above, but off the root.
- "^/(wp-.*)$" => "wordpress/$1",
- "^/xmlrpc.php$" => "wordpress/xmlrpc.php",
- "^/(.*)?$" => "wordpress/index.php/$1",
- )
- }
Any questions, let me know!
Banged out a quick script for backing up a directory containing a bunch of bzr depots, for use with rsnapshot:
To use:
- Save to /usr/local/bin/backup_bzr.py
- chmod u+x /usr/local/bin/backup_bzr.py
- Edit /etc/rsnapshot.conf and add:
- backup_script /usr/local/bin/backup_bzr.py . [root dir of your bzr dirs] localhost/bzr
Update: Just realized that maybe this isn’t as useful as I thought.
Seeing as how bzr is self-contained, you could probably just rsync the entire directory and get away with it that way. D’oh. So used to old-style VCS that need a separate backup process than ‘cp’.
I’ll leave this code here in case anyone else finds it useful.
- #!/usr/bin/python
- import os
- import subprocess
- import sys
- class App(object):
- def Setup(self):
- # TODO: Proper command line parsing
- if len(sys.argv) < 2:
- print 'Invalid arguments. Specify a destination directory, as well as root directory of bzr depots.'
- return -1
- self.BackupDirectory = sys.argv[1]
- self.RootDirectory = sys.argv[2]
- return 0;
- def IsBzrDirectory(self, p):
- return os.path.exists(os.path.join(p, '.bzr'))
- def RunCommand(self, c):
- print c
- p = subprocess.Popen(c, shell=True)
- if p.wait() != 0:
- raise Exception('Failure running command.')
- def BackupBzrDirectory(self, p):
- backupDirectory = os.path.join(self.BackupDirectory, os.path.split(p)[-1])
- if not os.path.exists(backupDirectory):
- cmd = 'bzr init %s'%(backupDirectory)
- self.RunCommand(cmd)
- pwd = os.getcwd()
- os.chdir(backupDirectory)
- cmd = 'bzr pull %s'%(p)
- self.RunCommand(cmd)
- os.chdir(pwd)
- return 0
- def Run(self):
- e = self.Setup()
- if e != 0:
- return e
- if self.RootDirectory != None:
- for dirName in os.listdir(self.RootDirectory):
- fqp = os.path.join(self.RootDirectory, dirName)
- if self.IsBzrDirectory(fqp):
- e = self.BackupBzrDirectory(fqp)
- if e != 0:
- return e
- return 0
- if '__main__' == __name__:
- sys.exit(App().Run())
I’ve been mussing around lately with some web programming, and couldn’t find a nice dependency free javascript file for creating combo boxes. Hopefully this is useful to someone out there.
Follow this link for a working example.
Note that I haven’t tested this on anything except Firefox 3.1 on Linux. Any reports on success/failures on other OS/platforms would be appreciated.
-e-
UPDATE:
Some issues are found on non Firefox/Linux browsers (as to be expected.
). I’ll post a table here that I’ll update as I fix these issues. Any one with suggestions, fixes, it would be appreciated.
| Browser & Version | OS & Version | Works? |
|---|---|---|
| Firefox 3.1 | Gentoo | Yes |
| IE 7 | WinXP | No |
| Google Chrome | Vista | No |
I do my best to keep this blog about technical topics (if only I tried as hard to post regularly!), but if you’re aware of the state of our economy and how it’s impacting the games industry, you’ll forgive me this straying.
Over the past few weeks several studios have closed either partially or completely. I’ve been lucky to keep my employment, but a great many friends of mine have not been quite so fortunate.
I’m not sure the best way I can help these fine folks, but the only thing I can think of is to list them here, with links to their LinkedIn profiles. If I missed you, or if you prefer to remain off this list, please let me know.
Recruiters, please help these fine folk.
| Game Designers: | |
|---|---|
| Martin Blackmore | (LinkedIn) |
| John Grimm | (LinkedIn) |
| Tim Lewinson | (LinkedIn) |
| Josh Bridge | (LinkedIn) |
| UI Engineers: | |
| Gavin Wilson | (LinkedIn) |
| Rendering Engineers: | |
| Mike Perzel | (LinkedIn) |
| Paul Richardson | (LinkedIn) |
| Matt Carter | (LinkedIn) |
| Chris Khoo | (LinkedIn) |
| Gameplay Engineers: | |
| Justin Heyes-Jones | (LinkedIn) |
| David Ferguson | (LinkedIn) |
| Justin Reynen | (LinkedIn) |
| Math / Physics / AI Engineers: | |
| Tony Bergelt | (LinkedIn) |
| Concept Artists: | |
| Chad Smith | (LinkedIn) |
| Animators: | |
| Kimberly Sanchez | (LinkedIn) |
| Mike Ferraro | (LinkedIn) |
| Level Designers: | |
| Brad Hines | (LinkedIn) |
| Rebecca Lathangue | (LinkedIn) |
| Kris Tetrault | (LinkedIn) |
| Phillip Meilleur | (LinkedIn) |
| QA/Dev Support: | |
| Chris Savory | (LinkedIn) |
| Brad Kavanagh | (LinkedIn) |
| Cam MacKinnon | (LinkedIn) |
| Production: | |
| Gio Corsi | (LinkedIn) |
| Lesley Crawford | (LinkedIn) |
| Daryl Smith | (LinkedIn) |
| Ed Tam | (LinkedIn) |
| Character Modellers: | |
| Zeynep Cameron | (LinkedIn) |
| Environment Artists: | |
| Mirna Cruz | (LinkedIn) |
| Mark Lawson | (LinkedIn) |
| Jesse Daniel | (LinkedIn) |
Updated: Added Justin Reynen, Gavin Wilson, Phil Meilleur, Justin Heyes-Jones, Cameron MacKinnon, Daryl Smith. Remind me if I forgot anyone.
(Feb 1st): Updated: added Mirna Cruz, Mark Lawson and Zeynep. Couldn’t find Jesse Daniel on LinkedIn; someone throw me a link for him and I’ll put it up.
(Feb 2nd): Got Jesse Daniel on the list. Any more?
(Feb 2nd, later that day): Added Ed Tam. Man, it gets more depressing the more I add to this list.
Two weeks ago, Microsoft organized an online event they called “Game With Dev” as we’ve officially launched Turok. I’ve never heard of this before (although apparently it’s not a new thing), but the idea is was sheer genius.
Aside from getting my ass handed to me by the community (hey, I was busy coding during production; not goofing around and playing games, *cough* Lenzin! *cough*
), it was great to see people trying to reach through to the team: before I started playing I started receiving friend invites, as well as messages detailing “what-would-be-soooo-cool-as-DLC”. It was really good to see people enjoying the game, and feeding back (particularly since forums seem to be more of a form of cathartic venting then actual constructive feedback).
I wouldn’t be surprised to see this sort of event with an MMO or some such, but it never struck me as something possible, or even enjoyable, for your average FPS gamer. I’m glad that Microsoft is heading these types of events, it definitely makes life a lot more enjoyable as a game developer.
I’ve always wanted to go to conferences, and aside from E3 back in 2001, I haven’t really lived up to it.
I’m keeping a list of nearby conferences to Vancouver/Seattle here. Check it out, and leave any comments you have on this post.
Hopefully someone else finds this useful. If not, it’s useful for me!
After my backup fiasco a couple weeks ago, I figured I should investigate backups, and see what exactly it is in a backup solution that I am looking for.
In reading up on the subject, I understood probably the best way to go about it is to do a base line full backup, and then a set of differentials. I ended up writing a neat little system in strictly bash and base UNIX tools, and it was actually getting pretty useful until I spotted rsnapshot.
Man, that’s one neat little package, and it’s super simple, easy and straight forward to set up.
In the end, I only had to write one ‘custom’ script, which was to backup my svn repositories, and it was off to the races.
If anyone’s interested in the source to my bash-based engine, let me know. It definitely taught me a lot about bash scripting!
As my previous post has stated, my posts have all but been wiped out.
That said, through various Internet caches, I’ve begun to recover my old posts, ordered by the ones it seems people are requesting most.
Let me know if you got here and couldn’t find what you’re looking for!
A failed server partition resize has blown away all my blog postings. Dammit! I thought I’d backed up everything, but I suppose it’s fathomable I might miss something that late at night.
Regardless, the server is running better than ever, but I think my next project I blog about will be a set of backup scripts….
See ya in a bit.
