Archive for February, 2009

irssi logging question

I have recently upgraded my home server from Ubuntu 7.10 to Ubuntu 8.10. I have been using irssi on this box for quite a while now and the logging has been just fine. Until this recent upgrade that is.

Below is what the my logs looked like before I did the upgrade:

21:47 < etank> someone told me that it was the way my client was set up
21:47 < etank> or a mode on my nick
21:47 < etank> i gots no idea
21:47 < klb> do a /mode etank
21:48 < etank> Your user mode is +ei
21:48 < klb> ah.. +i is invisible
21:48 < etank> oh
21:48 < klb> I see the channels in your whois that I share with you
21:48 < etank> now try me

This is what it looks like now:

12:30 4/<gc c4/ etankg4/>g e?/Sup3rkiddo: nice rant
12:30 4/<gc c4/ etankg4/>g e?/i had never thought of it that way before myself
12:30 4/<gc c4/ etankg4/>g e?/but it sure makes sense to me
12:31 4/<gc 2/Sup3rkiddgc4/>g eetank, wow, someone is alive :D.. thanks :)
12:31 4/<gc c4/ etankg4/>g e?/np.
12:32 4/<gc c4/ etankg4/>g e?/i just tried it out on my box (a, b = b, a)
12:32 4/<gc c4/ etankg4/>g e?/all it did was move the memory reference around it looks like
12:37 4/<gc 2/Sup3rkiddgc4/>g eetank, yeah

I did not make any changes to the irssi config file. All I did was the OS upgrade and with that got the new version of irssi. Is anyone else seeing this kind of behavior?

Thanks in advance for any help you provide.

6 Comments

AVUpdater.py

The servers in our DMZ do not have any access to the outside world. Getting Symantec dat files onto the DMZ AV server was kind of a pain. I would manually download the latest file (when I remembered) and then copy it to the correct directory on the server. I was getting kind of tired of manually doing this and add to that it was only happening about 2 times a month. Today I decided that I would write a script in python to take care of getting the correct file and moving it to the right location for me.  I have not set it up as a scheduled task yet but I may in the future. Here is what I came up with:

Disclaimer: I know that this may not be the best code written. I am still learning so please make comments that could improve on what is here. Thanks.

#!/usr/bin/env python

import datetime
from ftplib import FTP
import shutil, os

### Config stuff ###
# FTP site to connect to
ftpsite = 'ftp.symantec.com'

# Directory where the files are stored on the FTP server
directory = 'AVDEFS/symantec_antivirus_corp/xdb/'

# Set a variable for todays date like Feb 03 to match to
today = datetime.datetime.now().strftime("%b %d")

# Array to hold the directory listing of the remote server
data = []

# Set the directory on the DMZ AV server to copy to
destDir = r'\\SomeRemoteAvServer\RemoteDir'

def handleDownload(block):
    file.write(block)
    print ".",

# Find the file that matches todays date
def getFilename(data):
    for line in data:
        perms, x, y, z, size, month, day, time, filename = line.split()
        if len(day) == 1:
            day = '0' + day
        timestamp = month + ' ' + day
        if timestamp == today:
            return filename

def compareFileSize(filename,destFile):
    """
    Compares src file to destFile to see if they are the same size.
    """
    if os.path.getsize(filename) == os.path.getsize(destFile):
        return 1
    else:
        return 0

# Open a connection to the FTP server
ftp = FTP(ftpsite)

# Log in as anonymous
print 'Logging in.'
print ftp.login()

# Change to the directory where the files are stored
ftp.cwd(directory)

# Get a directory listing
ftp.dir(data.append)

# Get the file that matches todays date from the directory listing
filename = getFilename(data)

print 'Opening local file ' + filename
file = open(filename, 'wb')

# Download the file a chunk at a time
# Each chunk is sent to handleDownload
# We append the chunk to the file and then print a '.' for progress
# RETR is an FTP command
print 'Getting ' + filename
ftp.retrbinary('RETR ' + filename, handleDownload)

# Clean up time
# Close the local file
print
print 'Closing file ' + filename
file.close()

# Disconnect from the FTP server
print 'Closing FTP connection'
print ftp.close()

destFile = os.path.join(destDir,filename)

# Now copy the file to the AV server in the DMZ if it does not already exist
# then remove it from the local system.
if os.path.isfile(destFile):
    print 'The file %s is already on the server.' % filename
    os.remove(filename)
else:
    print 'Copying the file to %s' % destDir
    shutil.copy2(filename, destDir)
    # Compare the two files to make sure they copied correctly
    if compareFileSize(filename, destFile):
        print 'The file looks to have copied fine. Deleting the local copy now.'
        os.remove(filename)
    else:
        print 'Something seems to have gone wrong. The file did not copy correctly to %s' % destDir

2 Comments