Weblog Entries for June 2003

Friday, June 27, 2003

Using Twisted for Port Forwarding

Earlier this afternoon, I blundered across a post [1] by Paul Moore, on python-list [2] which showed how to use Twisted [3] for port forwarding. Here's the relavent snippet:

$ mktap portforward -p 8000 -h remote -d 20
$ twistd -f portforward.tap
[1]http://mail.python.org/pipermail/python-list/2003-June/170606.html
[2]http://mail.python.org/mailman/listinfo/python-list
[3]http://www.twistedmatrix.com/

Saved Friday, June 27, 2003 at 03:25 PM

Thursday, June 26, 2003

Using jEdit as %EDITOR% on Windows

With jEdit 4.2 (currently in development), jEdit can be used by other applications as an external editor. Using the -wait command line argument, jEdit can open a view and wait for the view or buffer to be closed before the process exits. Note that this works whether or not jEdit is already running.

With the following in my "AUTOEXEC.BAT" file, I can use jEdit to edit commit messages when using CVS or Subversion:

SET EDITOR=c:\j2sdk1.4.2b2\bin\java -jar c:\jEdit\jedit.jar -wait -newplainview

Note that this will NOT work using the jEdit Launcher for Windows, as that doesn't handle all command line arguments that jEdit supports.

Saved Thursday, June 26, 2003 at 10:10 AM

Monday, June 23, 2003

Dealing with SF.net's Anonymous CVS Access Timeouts

These days, most of my attempts to do anonymous checkouts or updates from SF.net's CVS repositories result in timeouts. For projects I'm a member of, I can use my account, but for others I just have to keep trying until an attempt doesn't timeout. After getting sick of doing that, I wrote a little script to do it for me.

The script below keeps trying to update until it's successful. After each failed attempt, it pauses for 5 seconds before trying again.

#!/usr/bin/env python

import os, sys, time

DEFAULT_CVS_ARGS = '-z9 -q up -dP'
SLEEP = 5   # seconds

def main(args=None):
        if args is None:
                args = sys.argv
        cvs_args = ' '.join(args[1:])
        if not cvs_args:
                cvs_args = DEFAULT_CVS_ARGS
        cmd = 'cvs %s' % cvs_args
        print 'running %s...' % cmd
        while 1:
                r = os.system(cmd)
                if not r:
                        break
                for i in range(SLEEP):
                        time.sleep(1)

if __name__ == '__main__':
        try:
                main()
        except KeyboardInterrupt:
                pass

# :indentSize=4:lineSeparator=\n:noTabs=true:tabSize=4:

Here's what it looks like running:

C:\sandbox\ctypes>cvsup
running cvs -z9 -q up -dP...
cvs [update aborted]: Error reading from server cvs.sourceforge.net: -1
cvs [update aborted]: Error reading from server cvs.sourceforge.net: 0
cvs [update aborted]: Error reading from server cvs.sourceforge.net: 0
cvs [update aborted]: Error reading from server cvs.sourceforge.net: 0
cvs [update aborted]: Error reading from server cvs.sourceforge.net: -1
cvs [update aborted]: Error reading from server cvs.sourceforge.net: 0
cvs [update aborted]: Error reading from server cvs.sourceforge.net: 0
cvs [update aborted]: Error reading from server cvs.sourceforge.net: 0
cvs [update aborted]: Error reading from server cvs.sourceforge.net: -1
cvs [update aborted]: Error reading from server cvs.sourceforge.net: 0
P setup.py
M samples/Windows/FindFile.py
M samples/Windows/wtl/readme.txt
P source/_ctypes.c
P source/callproc.c
P source/ctypes.h
P win32/com/register.py
P win32/com/server.py
P win32/com/samples/server/test_w32.py
P win32/com/tools/readtlb.py

C:\sandbox\ctypes>

Saved Monday, June 23, 2003 at 10:45 AM

Friday, June 20, 2003

Changing Keyword Expansion for a File in CVS

A co-worker of mine, Tim Perry, sent me a useful link [4] today.

If you've ever used cvs, at some point you've probably added an image or some other binary file to the repository, w/o using cvs add -kb <filename>. Here's an example of using cvs admin to fix the problem:

$ echo '$Id$' > kotest
$ cvs add -m"A test file" kotest
$ cvs ci -m"First checkin; contains a keyword" kotest
$ cvs admin -kb kotest
$ cvs update -A kotest
# For non-unix systems:
# Copy in a good copy of the file from outside CVS
$ cvs commit -m "make it binary" kotest
[4]http://www-es.fernuni-hagen.de/cgi-bin/info2html?(cvs)Binary%20howto

Saved Friday, June 20, 2003 at 03:20 PM

Tuesday, June 17, 2003

Folding VB Code in jEdit using Configurable Fold Handler Plugin

Earlier today, version 0.4 of the Configurable Fold Handler Plugin was announced [5] on jedit-devel. Using the following regexps, one can fold VB code. Improvements or suggestions welcome.

Fold start string:
^(?:Public|Private)?\s*\b(?:Sub|Function|Property|Type)\b
Fold end string:
^End\s+(?:Sub|Function|Property|Type)\b
[5]http://marc.theaimsgroup.com/?l=jedit-devel&m=105584623401830&w=2

Saved Tuesday, June 17, 2003 at 12:11 PM

Monday, June 16, 2003

HOWTO: Central Gentoo Mirror for Internal Network

In this week's Gentoo Weekly Newsletter [6], there's a link to an article [7] on Gentoo Forums [8] on setting up a local rsync mirror for portage.

[6]http://www.gentoo.org/news/en/gwn/20030616-newsletter.xml
[7]http://forums.gentoo.org/viewtopic.php?t=59134
[8]http://forums.gentoo.org/

Saved Monday, June 16, 2003 at 01:05 PM

Sunday, June 15, 2003

First Release of SendKeys Module for Python

I've just released SendKeys [9] module 0.3 for Python. SendKeys is a Python module for Windows (R) which can be used to send one or more keystrokes or keystroke combinations to the active window.

It's been a little while in coming, as I started it roughly 6 or 7 weeks ago, but it's already been through a few iterations. First, I wrote the low-level win32 code, using ctypes [10]. Second, I wrote a Python extension module using Pyrex [11], instead of ctypes . Lastly, I re-wrote the extension module in c.

[9]http://www.rutherfurd.net/python/sendkeys/
[10]http://starship.python.net/crew/theller/ctypes.html
[11]http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/

Saved Sunday, June 15, 2003 at 08:10 AM

Monday, June 02, 2003

A Subversion plugin for jEdit would be nice

I came across an announcment [12] of a Subversion plugin for Eclipse [13]. I'd love to see one for jEdit. It's written using svnup [14], so a jEdit plugin should be possible - maybe as a VFS?

[12]http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=38418
[13]http://subclipse.sourceforge.net
[14]http://svnup.tigris.org/

Saved Friday, June 06, 2003 at 07:51 PM

Exporting an X Session

Taken from this week's Gentoo Linux Newsletter [15].

[15]http://www.gentoo.org/news/en/gwn/20030602-newsletter.xml

Code listing 9.1: Local machine:

// This command allows the machine with the IP 192.168.1.3 to connect
# xhost +192.168.1.3

On the remote machine, you need to export the $DISPLAY variable to your local machine. After that, you should be ready to run GUI programs remotely.

Code listing 9.2: Remote machine:

# export DISPLAY="192.168.1.2:0.0"
# gvim /etc/passwd
// You should see gvim open on your local machine with the contents
// of the remote machine's /etc/passwd file.

Note

This is very unsecure and not recommended since everything you type including passwords will be transmitted over the network unencrypted.

To tunnel the connection over SSH and thus encrypt the traffic edit your /etc/sshd2_config file.

Code listing 9.3: /etc/sshd2_config:

// Add or edit the following line
ForwardX11     yes

Now connect from the local machine to the remote machine via ssh and start your X application.

Code listing 9.4: Remote machine:

# gvim /etc/passwd
// You should see gvim open on your local machine with the contents
// of the remote machine's /etc/passwd file.

Notice that you don't have to set the DISPLAY variable, ssh automagically does that for you. You do however have to allow access to your local machine's X server (see above).

Saved Friday, June 06, 2003 at 07:47 PM

View 2003, latest entries, or archive <../../archive.html>