Printing/writing an integer to a file

2006-11-16 Thread PS

Friends,

I am new to python and did search on the web on how to achieve this:
( I am trying to append the line numbers to all the lines of a file for now)

Thanks!!

=
import os, sys

fileName = os.path.join("C:", "temp", "x1.txt")
fileobject = open(fileName, 'r')
outputDir = "C://temp//"
linenumber = 0
fileName1 = outputDir + "x2.txt"
fileobject1 = open(fileName1, 'w')
while (1):
   L = fileobject.readline()
   if L=="":
   print "**Done"
   break
   linenumber += 1
   fileobject1.write(ln)
   fileobject1.write(":: "+ L)

fileobject1.close()
=

--
Regards,
Prem
-- 
http://mail.python.org/mailman/listinfo/python-list

undefined reference to `init_warnings' when compiling after freeze...

2009-02-24 Thread PS
Hello Python users

I am trying to compile .py files using freeze with Python 2.6.1, but I
get an error even when trying with hello.py from the examples.

Freeze semes to do its work (last lines only):

p...@linux-s7f4:~/soft/Python-2.6.1/Tools/freeze> python freeze.py
hello.py

generating table of frozen modules
Warning: unknown modules remain: _bisect _collections _ctypes
_functools _heapq _locale _random _socket _ssl _struct array binascii
cPickle cStringIO fcntl itertools math operator readline select strop
termios time
Now run "make" to build the target: hello

Now comes make:

p...@linux-s7f4:~/soft/Python-2.6.1/Tools/freeze> make
gcc -pthread  -Xlinker -export-dynamic config.o frozen.o
M_BaseHTTPServer.o M_FixTk.o M_SocketServer.o M_StringIO.o
M_Tkconstants.o M_Tkinter.o M_UserDict.o M___future__.o M___main__.o
M__abcoll.o M__threading_local.o M_abc.o M_base64.o M_bdb.o M_bisect.o
M_cmd.o M_codecs.o M_collections.o M_copy.o M_copy_reg.o
M_ctypes.oM_ctypes___endian.o M_ctypes__macholib.o
M_ctypes__macholib__dyld.o M_ctypes__macholib__dylib.o
M_ctypes__macholib__framework.o M_ctypes__util.o M_difflib.o M_dis.o
M_distutils.o M_distutils__dep_util.o M_distutils__errors.o
M_distutils__log.o M_distutils__spawn.o M_distutils__sysconfig.o
M_distutils__text_file.o M_distutils__util.o M_doctest.o
M_dummy_thread.o M_dummy_threading.o M_email.o M_email___parseaddr.o
M_email__base64mime.o M_email__charset.o M_email__encoders.o
M_email__errors.o M_email__feedparser.o M_email__message.o
M_email__mime.o M_email__parser.o M_email__quoprimime.o
M_email__utils.o M_encodings.o M_encodings__aliases.o M_fnmatch.o
M_formatter.o M_ftplib.o M_functools.o M_genericpath.o M_getopt.o
M_getpass.o M_gettext.o M_glob.o M_heapq.o M_httplib.o M_inspect.o
M_keyword.o M_linecache.o M_locale.o M_macurl2path.o M_mimetools.o
M_mimetypes.o M_ntpath.o M_nturl2path.o M_opcode.o M_optparse.o M_os.o
M_os2emxpath.o M_pdb.o M_pickle.o M_pkgutil.o M_posixpath.o M_pprint.o
M_py_compile.o M_pydoc.o M_pydoc_topics.o M_quopri.o M_random.o M_re.o
M_repr.oM_rfc822.o M_shlex.o M_site.o M_socket.o M_sre_compile.o
M_sre_constants.o M_sre_parse.o M_ssl.o M_stat.o M_string.o M_struct.o
M_subprocess.o M_tempfile.o M_textwrap.o M_threading.o M_token.o
M_tokenize.o M_traceback.o M_tty.o M_types.o M_unittest.o M_urllib.o
M_urlparse.o M_uu.o M_warnings.o M_webbrowser.o /home/ps/app/lib/
python2.6/config/libpython2.6.a   -lpthread -ldl  -lutil -lm  -o hello
/home/ps/app/lib/python2.6/config/libpython2.6.a(posixmodule.o): In
function `posix_tmpnam':
/home/ps/soft/Python-2.6.1/./Modules/posixmodule.c:7079: warning: the
use of `tmpnam_r' is dangerous, better use `mkstemp'
/home/ps/app/lib/python2.6/config/libpython2.6.a(posixmodule.o): In
function `posix_tempnam':
/home/ps/soft/Python-2.6.1/./Modules/posixmodule.c:7034: warning: the
use of `tempnam' is dangerous, betteruse `mkstemp'
config.o:(.data+0x28): undefined reference to `init_warnings'
collect2: ld returned 1 exit status
make: *** [hello] Error 1


I tested it on OpenSuSe 11.0 and Ubuntu 8.10 with the same results.

Did somebody experienced the same problem?

With Python 2.5.1 it works without problems.

Thanks in advance
Pablo
--
http://mail.python.org/mailman/listinfo/python-list


Failed to build these modules:_ctypes

2009-04-24 Thread PS
Hello all

I can't install neither python 2.6.1 nor 2.6.2 because an error during
compilation of _ctypes module, I don't need the module but I don't
know how to instruct to skip it.

The plattform is Suse 11.0

The steps I performed are the following:

./configure  --prefix $HOME/app/Python-2.6.2
make

The last command from make with its error is the following

gcc -pthread -shared build/temp.linux-i686-2.6/home/ps/soft/
Python-2.6.2/Modules/_ctypes/_ctypes.o build/temp.linux-i686-2.6/home/
ps/soft/Python-2.6.2/Modules/_ctypes/callbacks.o build/temp.linux-
i686-2.6/home/ps/soft/Python-2.6.2/Modules/_ctypes/callproc.o build/
temp.linux-i686-2.6/home/ps/soft/Python-2.6.2/Modules/_ctypes/
stgdict.o build/temp.linux-i686-2.6/home/ps/soft/Python-2.6.2/Modules/
_ctypes/cfield.o build/temp.linux-i686-2.6/home/ps/soft/Python-2.6.2/
Modules/_ctypes/malloc_closure.o build/temp.linux-i686-2.6/home/ps/
soft/Python-2.6.2/Modules/_ctypes/libffi/src/prep_cif.obuild/
temp.linux-i686-2.6/home/ps/soft/Python-2.6.2/Modules/_ctypes/libffi/
src/x86/ffi.o build/temp.linux-i686-2.6/home/ps/soft/Python-2.6.2/
Modules/_ctypes/libffi/src/x86/sysv.o -L/home/ps/app/Python-2.6.2/lib -
L/usr/local/lib -o build/lib.linux-i686-2.6/_ctypes.so
*** WARNING: renaming "_ctypes" since importing it failed: build/
lib.linux-i686-2.6/_ctypes.so: undefined symbol: ffi_prep_cif_machdep

Failed to find the necessary bits to build these modules:
bsddb185   dl imageop
sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for
the module's name.


Failed to build these modules:
_ctypes

running build_scripts

any idea?

Thanks in advance
Pablo
--
http://mail.python.org/mailman/listinfo/python-list


python _binary_ code

2009-07-13 Thread sanju ps
Hi

 Can anyone give me solution to create a python binary file (bytecode) other
than pyc file .So my source code be secure.. I am working on ubuntu 9.04
with python2.6.. I

Regards
Sanju
-- 
http://mail.python.org/mailman/listinfo/python-list


Launch my application if its not running

2009-08-05 Thread sanju ps
How to check whether my gui application is running or not.If its already
running i have to quit my program other wise i need to launch my program.
Can anybody suggest a solution to this

Regards
Sanju
-- 
http://mail.python.org/mailman/listinfo/python-list


handling kill signal

2009-08-06 Thread sanju ps
I want to handle a kill signal..In my program i wrote like this

def handler(signum, frame):
print "Signal",signum
delete_temp_file()
exit(1)
signal.signal(signal.SIGTERM, handler)

And when i tried pkill processid .program is exited but not deleting the
temp file
-- 
http://mail.python.org/mailman/listinfo/python-list