'ports.conf', if you're using ubuntu, is located @ '/etc/apache' (apache), '/etc/apache2' (apache2)
$ sudo gedit etc/apache2/ports.conf
Saturday, July 31, 2010
Friday, July 30, 2010
netwrokking
http://blog.ksplice.com/2010/07/learning-by-doing-writing-your-own-traceroute-in-8-easy-steps/
Sunday, July 25, 2010
to mount a disk in linux
all devices are listed as files in /dev
e.g. $ ls -l /dev
for a list of all devices in /dev
to filter it down to devices containing the string 'sda'
$ ls -l /dev | grep -i sda
which for example returns
ptysd
sda
sda1
sda2
sda5
sdb
... and more
then
$ sudo fdisk -l /dev/sda
fdisk in this case yields partition information for the device
fdisk --help for usage
also
$ cat /var/log/messages
e.g. $ ls -l /dev
for a list of all devices in /dev
to filter it down to devices containing the string 'sda'
$ ls -l /dev | grep -i sda
which for example returns
ptysd
sda
sda1
sda2
sda5
sdb
... and more
then
$ sudo fdisk -l /dev/sda
fdisk in this case yields partition information for the device
fdisk --help for usage
also
$ cat /var/log/messages
mod_wsgi
mod_wsgi is now the effective supercedent of mod_python
http://code.google.com/p/modwsgi/
ubuntu package = libapache2-mod-wsgi
ERROR
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
FIX - courtesy of Mohamed Aslam
http://mohamedaslam.com/how-to-fix-apache-could-not-reliably-determine-the-servers-fully-qualified-domain-name-using-127011-for-servername-error-on-ubuntu/
http://code.google.com/p/modwsgi/
ubuntu package = libapache2-mod-wsgi
ERROR
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
FIX - courtesy of Mohamed Aslam
http://mohamedaslam.com/how-to-fix-apache-could-not-reliably-determine-the-servers-fully-qualified-domain-name-using-127011-for-servername-error-on-ubuntu/
What is mod_python ?
mod_python
1. o'Reilly article by Gregory Trubetskoy
2. WikiPedia
but, most importantly, it appears that
MOD_PYTHON IS DEAD !
LONG LIVE MOD_WSGI !
WSGI Project Page @ Google Code
modpython-project-is-now-officially-dead
modpython-project-soon-to-be-officially-dead
from django
Blog Piece
StackOverflow Thread
1. o'Reilly article by Gregory Trubetskoy
2. WikiPedia
but, most importantly, it appears that
MOD_PYTHON IS DEAD !
LONG LIVE MOD_WSGI !
WSGI Project Page @ Google Code
modpython-project-is-now-officially-dead
modpython-project-soon-to-be-officially-dead
from django
Blog Piece
StackOverflow Thread
to run a pythonscript from ubuntu command line
to run a pythonscript from ubuntu command line
to execute script 'hw.py'
from the command line
in the director of 'hw.py' [i.e. if you entered 'ls' you would see hw.py in the listing)
first, make script executable by granting rights
$ sudo chmod +x hw.py
add the following line to the beginning of the script
#!/usr/bin/python
this instructs the shell to hand the script over to the the python runtime binary,
which is located /usr/bin/python
to execute script 'hw.py'
from the command line
in the director of 'hw.py' [i.e. if you entered 'ls' you would see hw.py in the listing)
first, make script executable by granting rights
$ sudo chmod +x hw.py
add the following line to the beginning of the script
#!/usr/bin/python
this instructs the shell to hand the script over to the the python runtime binary,
which is located /usr/bin/python
Wednesday, July 21, 2010
Tuesday, July 20, 2010
DocPy - Python Source Doc Gen
# docpy.py - david.barkhuizn@gmail.com
# 1. module methods - signature, followed by docstring
# 2. module fields ?
# 3. module classes
# class name, parent class, __init__ method parameters & docstring
# instance fields (get from self.? refs in __init__ method)
# ---------------------------------------------------------------
# ISSUES
# need to strip out classes before extracting method info
# can't handle multi-line method signatures
# ---------------------------------------------------------------
import sys
# ---------------------------------------------------------------
single_marker = '\'\'\''
double_marker = '\"\"\"'
# ---------------------------------------------------------------
class MethodInfo:
def __init__(self, method_name, params, docstrings):
'''
method_name - string
params - list of param name strings
'''
self.method_name = method_name
self.params = params
self.docstrings = docstrings
# ---------------------------------------------------------------
def load_text_file(file_path):
'''
return list of lines in text file @ 'file_path'
'''
try:
text_file = open(file_path, 'r')
text_block = text_file.read()
lines = text_block.split('\n')
text_file.close()
return lines
except Exception, err:
print('error during reading of text file %s' % file_path)
print(err)
return []
def src_file_path_from_cmdargs():
valid_args = []
for arg in sys.argv:
if arg.lower() not in ['docpy.py', 'python']:
valid_args.append(arg.lower())
return 'docpy.py'
if len(valid_args) != 1:
return ''
else:
return valid_args[0]
def get_sig_line_idxs(lines):
'''
lines = list of lines in python source file (in sequence)
'''
token = 'def '
indices = []
for i in range(len(lines)):
if lines[i].strip()[:4] == token:
indices.append(i)
return indices
def parse_method_sig(sig):
# e.g.' def parse_methodsig(sig):#comment '
sig = sig.strip()
# e.g.'def parse_methodsig(sig):#comment'
sig = sig[4:len(sig)]
# e.g.'parse_methodsig(sig):#comment'
i = sig.find('#')
if i != -1:
sig = sig[:i-1]
# e.g.'parse_methodsig(sig):
left = sig.find('(')
right = sig.rfind(')')
meth_name = sig[:left]
params = []
if right - left != 1:
params = sig[left+1:right]
params = params.replace(',', ' ')
got_double = True
while got_double == True:
got_double = (params.find(' ') != -1)
if got_double:
params = params.replace(' ', ' ')
params = params.split(' ')
return MethodInfo(meth_name, params, [])
def extract_single_line_docstring(docstring):
'''example of single line method docstring'''
lsingle = docstring.find(single_marker)
ldouble = docstring.find(double_marker)
marker = ''
left = -1
if lsingle != -1:
marker = single_marker
left = lsingle
elif ldouble != -1:
marker = double_marker
left = ldouble
else:
return ''
right = docstring.rfind(marker)
if (right != -1) and (right != left):
return docstring[left+3:right]
else:
return ''
def strip_leading_triplequotes(line):
left = line.find(single_marker)
if left == -1:
left = line.find(double_marker)
if left == -1:
return ''
return line[left + 3:]
def strip_trailing_triplequotes(line):
right = line.rfind(double_marker)
if right == -1:
right = line.rfind(double_marker)
if right == -1:
return ''
return line[:right]
def extract_docstrings(lines, meth_sig_idx, next_meth_sig_idx):
# determine line indices of starting and ending triple quotes
start = -1
end = -1
for i in range(meth_sig_idx + 1, next_meth_sig_idx):
line = lines[i]
sidx = line.find(single_marker)
if sidx == -1:
sidx = line.find(double_marker)
if sidx != -1:
if start == -1:
start = i
else:
end = i
break
if start == -1:
return []
elif end == -1:
single_line = extract_single_line_docstring(lines[start])
if single_line != '':
return [ single_line ]
else:
return []
else:
docstrings = []
for i in range(start, end + 1):
no_whitespace = lines[i].strip()
if i == start:
stripped = strip_leading_triplequotes(no_whitespace)
if stripped != '':
docstrings.append(stripped)
elif i == end:
stripped = strip_trailing_triplequotes(no_whitespace)
if stripped != '':
docstrings.append(stripped)
else:
docstrings.append(no_whitespace)
return docstrings
def get_method_info(lines, meth_sig_idx, next_meth_sig_idx):
method_info = parse_method_sig(lines[meth_sig_idx])
method_info.docstrings = extract_docstrings(lines, meth_sig_idx, next_meth_sig_idx)
return method_info
def mock_method(one, two, three, four):
print('vokol')
def display_module_method_info(meth_info):
print(meth_info.method_name)
for p in meth_info.params:
print(' ' + p)
for docstring in meth_info.docstrings:
print(docstring)
def main():
text_file_path = src_file_path_from_cmdargs()
lines = load_text_file(text_file_path)
sig_line_idxs = get_sig_line_idxs(lines)
module_methods_info = []
for i in range(len(sig_line_idxs)):
idx = sig_line_idxs[i]
if i < len(sig_line_idxs) - 1:
next_idx = sig_line_idxs[i + 1]
else:
next_idx = len(sig_line_idxs)
module_methods_info.append( get_method_info(lines, idx, next_idx) )
for meth_info in module_methods_info:
display_module_method_info(meth_info)
if __name__ == '__main__':
main()
Monday, July 19, 2010
Untangling Object Dependencies in MS-SQL-08
useful TechRepublic Blog
1. get a list of all system objects from sys.objects
name,object_id,parent_object_id,type
2. determine individual dependencies from sys.sql_dependencies
object_id, referenced_major_id
3. use a topological sort to untangle the list of dependencies to a simple dependency tree.
1. get a list of all system objects from sys.objects
name,object_id,parent_object_id,type
2. determine individual dependencies from sys.sql_dependencies
object_id, referenced_major_id
3. use a topological sort to untangle the list of dependencies to a simple dependency tree.
Sunday, July 18, 2010
setting up iburst driver for ubuntu 8-10 intrepid ibex
http://blog.hostinghabitat.com/2009/02/iburst-usb-modem-installation-tutorial.html
Saturday, July 17, 2010
yapyfin.py Python Yahoo Finance Client
Yahoo Finance exposes a large amount of historical US equity data via their html api. The python code below downloads the open-high-low-close-adjclose-volume data for British Petroleum (BP) = stock ticker symbol BP, between 1900/01/01 and 2010/07/18, to text file BP.csv
import httplib
httplib.HTTPConnection.debuglevel = 1
import urllib
def enc_quote(ticker, fromY, fromM, fromD, toY, toM, toD):
quote = dict()
quote['s'] = ticker
quote['a'] = fromM
quote['b'] = fromD
quote['c'] = fromY
quote['d'] = toD
quote['e'] = toM
quote['f'] = toY
quote['g'] = "d"
return urllib.urlencode(quote)
url_stem = 'http://ichart.yahoo.com/table.csv?'
quote_tokens = enc_quote('BP', '1900', '01', '01', '2010', '07', '18')
url = url_stem + "&ignore=.csv" + quote_tokens
f = urllib.urlopen(url)
body = f.read()
f.close()
try:
f = open('BP.csv', 'w')
f.write(body)
f.close()
except Exception, err:
print('ERROR: %s\n' % str(err))
Labels:
python,
python yahoo finance client,
service,
yahoo_finance
Thursday, July 15, 2010
PyMSSql - import _mssql - ImportError: DLL load failed: The specific module could not be found
under windows xp pro,
When attempting to import pymssql.py,
I experienced the following error:
"
import _mssql
ImportError: DLL load failed: The specific module could not be found
"
So this is all a bit cryptic, but after googling, which suggested using a windows diagnostic tool [ProcessMonitor] to locate the failing process, it turns out that what is missing is an (accessible) copy of 'mscvr71.dll', which can be downloaded off the net, and should be copied to 'c:\windows\system32\', or 'c:\windows\system\' if running 64bit windows.
you then need to run 'regsvr32 msvcr71.dll' from the command line, in the directory that you copied the dll to.
cant find entrypoint
if you get a 'cant find entrypoint' type error message, its actually still all ok, pymssql should run just fine by that point.
When attempting to import pymssql.py,
I experienced the following error:
"
import _mssql
ImportError: DLL load failed: The specific module could not be found
"
So this is all a bit cryptic, but after googling, which suggested using a windows diagnostic tool [ProcessMonitor] to locate the failing process, it turns out that what is missing is an (accessible) copy of 'mscvr71.dll', which can be downloaded off the net, and should be copied to 'c:\windows\system32\', or 'c:\windows\system\' if running 64bit windows.
you then need to run 'regsvr32 msvcr71.dll' from the command line, in the directory that you copied the dll to.
cant find entrypoint
if you get a 'cant find entrypoint' type error message, its actually still all ok, pymssql should run just fine by that point.
Tuesday, July 13, 2010
Sunday, July 11, 2010
Python Client Consumes WCF Web Service
End-Point = ABC
- Address
- Binding
- Contract
WSDL Components
definition
types
message
portType = interface implementation
operation
input
output
binding = abstract interface
operation
documentation
input
output
service
wsdl:port (name, binding)
x:address (location)
Example Publicly Accessible / iNet WSDL
GlobalWeather.com
- http://www.webservicex.com/globalweather.asmx?wsdl
wsf.cdyne.com
- http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL
thomas-bayer.com
- http://www.thomas-bayer.com/axis2/services/BLZService?wsdl
External Links
- Make a SOAP client with Python
- StackOverFlow - How can I consume a WSDL (SOAP) web service in Python?
- SourceForge - Python Web Services Project
Thursday, July 1, 2010
RSA ID Number Check-Sum Algorithm
infomation sourced from this site.
13 digit South African Identity Numbers have the following format
Calculation of Checksum Digit = Z
A = sum of digits in odd position (excluding last checksum digit)
B = sum of all the digits of the product of 2 and the number formed from the original be removing all the odd digits
C = A + B
Z = 10 - (second digit of C)
13 digit South African Identity Numbers have the following format
{YYMMDD}{G}{SSS}{A}{Z}
YYMMDD Date of birth
G Gender: 0-4 = Female, 5-9 = Male
SSS Sequence No. for DOB/G combination.
C Citizenship: 0 = SA, 1 = other
A generally, but not strictly = 8, 9
Z CheckSum Digit
Calculation of Checksum Digit = Z
A = sum of digits in odd position (excluding last checksum digit)
B = sum of all the digits of the product of 2 and the number formed from the original be removing all the odd digits
C = A + B
Z = 10 - (second digit of C)
Subscribe to:
Posts (Atom)