Sunday, July 29, 2007

My Linux System

I've upgraded my Linux system from Fedora Core 5 to Fedora 7 overnight with the help of the Internet and apt-get. Just one night with apt-get has made me abandon YUM. Now my system is spanking new, and the install/upgrade process also tidied up my system files in the process! E.g. /etc/fstab, /etc/modprobe.conf, /etc/grub.conf, etc.

1. Asus Pundit-R
2. Intel P4 3.0GHz Hyper-Threading
3. 512MB DDR SDRAM
4. 60GB Western Digital (IDE, 8MB cache, 3.5")
5. Samsung 40x CD-RW (IDE)
6. Fedora 7 (2.6.21-1.3228.fc7)

Here are some of my prevous computer related posts that I put in another blog. I'll just move them here for consistency sake.

Motive Certification



TR-069: DSL1000EU is Motive Baseline Certified Just received confirmation that our DSL1000EU has been Motive certified. Next step is to get DSL605EW the same certification as well. SSL verification need to be done properly.Hoping to get Siemens verification behind us - hope to do so next week.

DSL605EW is Motive certified. 'Nuff said.


A PUT script in Python+Apache



I finally managed to write a PUT script properly.

Initially I thought it was simply reading the file data from stdin and writing the contents out to a filename that is retrieved from the environment. Well, it used to be that simple on Unix/Linux. On Windows it is a lot more complicated.

  1. In Windows, file streams are in TEXT mode, even stdin!
  2. To fix this, "import msvcrt", msvcrt(sys.stdin.fileno(), os.O_BINARY)
  3. How do you know you are running Windows?
  4. "if sys.platform=='win32':"


Here is the code in all its glory:


#!"C:\Python24\Python.exe"
import os, sys, time
if sys.platform=='win32': import msvcrt

apacheHelp = '''This directive adds an action, which will activate cgi-script when a file is requested using the method of method. The cgi-script is the URL-path to a resource that has been designated as a CGI script using ScriptAlias or AddHandler. The URL and file path of the requested document is sent using the standard CGI PATH_INFO and PATH_TRANSLATED environment variables.'''
def reportError(errMsg):
print 'Content-Type: text/plain\r\n\r\n'
print errMsg

def debugEnv():
print 'Content-Type: text/plain\r\n\r\n'
for x in os.environ.keys():
print x,'=',os.environ[x]

def getenv(name):
try:
return os.environ[name]
except KeyError:
return ''

def writeFile(path, srcFD):
dstFD = open(path, 'wb')
numWrite = 0
while True:
buf = srcFD.read(1024)
if len(buf)==0: break
dstFD.write(buf)
dstFD.flush()
numWrite += len(buf)
dstFD.close()
return numWrite

# debugEnv()
def main():
pathInfo = getenv('PATH_INFO')
if (not pathInfo.startswith('/uploads/')):
reportError('Disallowed upload path ' + pathInfo)
sys.exit(1)
if pathInfo.endswith('/'):
reportError('Cannot upload file as a directory!')
sys.exit(2)

if sys.platform=='win32': msvcrt.setmode(sys.stdin.fileno(), (os.O_BINARY))
size = writeFile(getenv('PATH_TRANSLATED'), sys.stdin)

reportError('')
print '%d bytes written to %s\n' % (size, pathInfo)

if '__main__'==__name__:
main()



Rare error on Google?




No comments: