Re: usage of try except for review.

2016-02-29 Thread Ganesh Pal
"mount /nfs_mount1", "mount /cifs_mount1"]: try: if not run_cmd_and_verify(cmd, timeout=3600): return False except: pass logging.info("Setup and Creation Done !!!") Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Re: usage of try except for review.

2016-02-29 Thread Ganesh Pal
for cmd in ["mount /nfs_mount1", "mount /cifs_mount1"]: try: if not run_cmd_and_verify(cmd, timeout=3600): logging.error("mount Failed") return False except: pass logging.info(&q

Re: usage of try except for review.

2016-02-29 Thread Ganesh Pal
> I have tried down the code to Read "I have tried down the code to " as I have trimmed down the code as below Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Re: common mistakes in this simple program

2016-02-29 Thread Ganesh Pal
>> How do we reraise the exception in python , I have used raise not >> sure how to reraise the exception > > raise with no arguments will reraise the exception currently being handled. > > except Exception: > logging.error("something went wrong") > raise Thanks Ian for taking time and lo

Re: common mistakes in this simple program

2016-02-29 Thread Ganesh Pal
On Mar 1, 2016 12:06 AM, "Chris Angelico" wrote > > You're falling into the trap of assuming that the only exception you > can ever get is the one that you're planning for, and then handling. Ok sure ! > ALL exceptions as though they were that one. Instead catch ONLY the > exception that you're

Re: common mistakes in this simple program

2016-03-15 Thread Ganesh Pal
On Tue, Mar 1, 2016 at 2:41 AM, Martin A. Brown wrote: > Please read below. I will take a stab at explaining the gaps of > understanding you seem to have (others have tried already, but I'll > try, as well). > > I am going to give you four different functions which demonstrate > how to use excep

Python Fabric on Windows :

2014-10-26 Thread Ganesh Pal
windows case I guess. please suggest if you foresee problems using fabric on Windows and also suggest an alternative to this if available. . Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Fabric on Windows :

2014-11-01 Thread Ganesh Pal
On Tue, Oct 28, 2014 at 5:00 PM, Robin Becker wrote: > > I found fabric on windows quite hard, but I have managed to use it. For > ssh I think I had to use the putty tools eg plink to do remote work. > > On the other hand I find plumbum much easier > > http://tomerfiliba.com/blog/Plumbum/ > > Than

Python Logging and printf()

2014-11-21 Thread Ganesh Pal
l be logged into the logfile ? (2) I feel the need to retain few print(), how do I ensure the print() messages are also logged into the log file. Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Logging and printf()

2014-11-24 Thread Ganesh Pal
Hi Chris, Thanks for the comments , Iam planning to use logging handlers ( StreamHandler and FileHandler) to achieve my requirement . Any quick reference example to this will be great , Iam on Python 2.7 , Iam referring the python docs for mow. Regards, Ganesh On Fri, Nov 21, 2014 at 5:25 PM

PYTHON LOGGING with StreamHandler and FileHandler

2014-11-24 Thread Ganesh Pal
-11-24 11:18:12,355 - myapp - ERROR - We have a problem 2014-11-24 11:18:12,356 - myapp - INFO - While this is just chatty error abort # echo > /var/tmp/myapp1.log # python modified_logger.py 2014-11-24 11:18:45,872 - myapp - ERROR - We have a problem 2014-11-24 11:18:45,872 - myapp - INFO - W

Re: PYTHON LOGGING with StreamHandler and FileHandler

2014-11-25 Thread Ganesh Pal
myapp1.log 2014-11-25 13:16:35,772 - myapp - ERROR - We have a problem 2014-11-25 13:16:35,773 - myapp - INFO - While this is just chatty Regards, Ganesh On Tue, Nov 25, 2014 at 12:17 PM, dieter wrote: > > You read the handler related documentation of the logging module. > When

Python and GUI development

2014-12-01 Thread Ganesh Pal
Hi folks, I want to design a GUI interface for my project . I wanted it to use it Python and it has to work on freebsd . Please provide me the latest trends for GUI development with python. Regard s Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Re: Python and GUI development

2014-12-01 Thread Ganesh Pal
Thanks for the bunch of suggestion , I have decided to go with PYQt for now : ) On Tue, Dec 2, 2014 at 4:13 AM, Rod Person wrote: > On Mon, 1 Dec 2014 23:13:32 +1100 > Chris Angelico wrote: > > > On Mon, Dec 1, 2014 at 10:55 PM, Ganesh Pal > > wrote: > > > H

Python re.search simple question

2014-12-07 Thread Ganesh Pal
-based: [prev 0 , now 1]' >>> if (re.search(pattern,text)): ...print "Hi" ... else: ... print "BYE" ... BYE Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Re: Python re.search simple question

2014-12-07 Thread Ganesh Pal
Thanks guys , I escaped the '[' character and my issue is sloved .. Thank you guys u all rock :) Regards, Ganesh On Mon, Dec 8, 2014 at 12:41 PM, Zachary Ware wrote: > On Mon, Dec 8, 2014 at 12:52 AM, Ganesh Pal wrote: > > Hi Folks , > > > > This might seem

List Comprehensions

2014-12-21 Thread Ganesh Pal
tart() (b) * Is there anything that I need to consider while using list comprehension with threads ?* Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Playing with threads

2015-01-07 Thread Ganesh Pal
above be achieved without threads ? I prefer keep ing code simple .threads can become confusion when this workflow grows larger Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Python : writing to a file

2015-01-10 Thread Ganesh Pal
file fprmat ? (b) how will I take care that the below format is repeated in the .txt file ( i.e column and row spacing) DAY OF THE WEEK [SPACE] START TIME [ SPACE] ENDTIME{SPACE] (c) how do I add START TIME [ SPACE] ENDTIME{SPACE] columns Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Re: Playing with threads

2015-01-10 Thread Ganesh Pal
Thanks I read subprocess module this answered most of my question ,thanks a lot for the replies On Thu, Jan 8, 2015 at 9:46 AM, Terry Reedy wrote: > On 1/7/2015 9:00 PM, Ganesh Pal wrote: > >> Hi friends, >> >> I'm trying to use threads to achieve the below work

Re: Python : writing to a file

2015-01-11 Thread Ganesh Pal
off the output . below is the complete flow. # cat get_day.py #!/usr/bin/python import time f = open ('test_a.txt','wb+') DAY = time.strftime("%A") f.write(DAY) f.close() Throttling-1# python get_day.py node-1# cat test_a.txt // This didn't give a

Few coding suggestions

2015-01-11 Thread Ganesh Pal
"%A %H:%M") gen = yield_times() for ii in range(15): print gen.next() Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Few Coding suggestions - resending

2015-01-11 Thread Ganesh Pal
"%A %H:%M") gen = yield_times() for ii in range(15): print gen.next() Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Re: Few Coding suggestions - resending

2015-01-11 Thread Ganesh Pal
On Sun, Jan 11, 2015 at 7:57 PM, Dave Angel wrote: >> >> > No idea how that represents "a difference of 5 minutes". So I'll take a > totally wild guess that you meant: > > Sunday 23:50 23:55 > Monday 00:00 00:05 > Monday 00:10 00:15 > Monday 00:20 00:25 > Monday 00:30 00:35 > > which would have

Re: Few Coding suggestions - resending

2015-01-12 Thread Ganesh Pal
On Mon, Jan 12, 2015 at 8:42 AM, Ganesh Pal wrote: > On Sun, Jan 11, 2015 at 7:57 PM, Dave Angel wrote: >>> >>> >> No idea how that represents "a difference of 5 minutes". So I'll take a >> totally wild guess that you meant: >> >> Su

Re: Few Coding suggestions - resending

2015-01-12 Thread Ganesh Pal
#x27;wb') for ii in range(10): a,b,c = gen.next() res = "{0} {1} {2} \n".format(a,b,c) print res, f.write(res) f.close() Gpal On Mon, Jan 12, 2015 at 3:23 PM, Ganesh Pal wrote: > On Mon, Jan 12, 2015 at 8:42 AM, Ganesh Pal wrote: >> On Sun, Jan 11, 20

How to terminate the function that runs every n seconds

2015-01-14 Thread Ganesh Pal
t time def printit(): threading.Timer(2, printit).start() print "EXECUTED SLEEP" printit() print "hi" time.sleep(4) print "hi" time.sleep(5) Output: node-1# python file_01.py EXECUTED SLEEP hi EXECUTED SLEEP EXECUTED SLEEP EXECUTED SLEEP Regards, Ga

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Ganesh Pal
Corrected Typos . >a) How to I prevent the execution of Print "EXECUTED SLEEP" after 4 > seconds ? , current this is running in an infinite loop On Wed, Jan 14, 2015 at 6:37 PM, Ganesh Pal wrote: > Iam using Linux and Python 2.7 and playing with the threading.Timer mo

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Ganesh Pal
t : Throttling-1# python file_02.py EXECUTED SLEEP hello EXECUTED SLEEP On Wed, Jan 14, 2015 at 6:39 PM, Ganesh Pal wrote: > Corrected Typos . > >>a) How to I prevent the execution of Print "EXECUTED SLEEP" after 4 >> seconds ? , current this is running in a

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Ganesh Pal
This is bit urgent and I all stuck form last few hours :( On Wed, Jan 14, 2015 at 6:37 PM, Ganesh Pal wrote: > Iam using Linux and Python 2.7 and playing with the threading.Timer module. > > I had the below question on the same. > > (a) How to I prevent the execution the

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Ganesh Pal
; matches the requested time. Sure will keep this in mind Regards , Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Python : parsing the command line options using optparse

2014-02-25 Thread Ganesh Pal
Hi Folks , Iam newbie to Python, Iam trying to use optparse module and write a script that will parse the command line options ..I had to use opt parse instead of argparse because by host Operating system is still using python 2.6 Below is the simple program ( Feel free to correct the error

Re: Python : parsing the command line options using optparse

2014-02-26 Thread Ganesh Pal
On Tue, Feb 25, 2014 at 9:55 PM, Peter Otten <__pete...@web.de> wrote: >As you are just starting I recommend that you use argparse instead of optparse. I would love to use argparse but the script that I plan to write has to run on host machines that Python 2.6 I have freebsd clients with py

Re: Python : parsing the command line options using optparse

2014-02-26 Thread Ganesh Pal
On Wed, Feb 26, 2014 at 4:57 PM, Peter Otten <__pete...@web.de> wrote: > > If you stick with optparse just pass the options without '=' > > -qXOR > > and > > -q XOR > > should both work. > > Thanks Peter and Simon for the hints it worked : ) without ' =' # Python corrupt.py -o INODE -p /ifs/

Re: Python : parsing the command line options using optparse

2014-02-27 Thread Ganesh Pal
> > They must be running an older version of FreeBSD since the default version > of python is 2.7. > > There is a FreeBSD package for argparse, the command would be something > like >pkg_add -r install py26-argparse > > > Rod > > Yes Iam running a older version of FreeBSD ( Iam actually run

Re: Python : parsing the command line options using optparse

2014-03-01 Thread Ganesh Pal
> > > > Thanks Peter and Simon for the hints it worked : ) without ' =' > > # Python corrupt.py -o INODE -p /ifs/1.txt -q SET -f 1 > > Current Default Choice : > > Choice: INODE > Choice: SET > Choice: 1 > > > > Iam done with the command line parsing but got stuck while trying to implement sw

Re: Python : parsing the command line options using optparse

2014-03-01 Thread Ganesh Pal
> > handler = object_type_dictionary[options.object_type] # look up the > function > handler() # call it > > The last two lines could also be merged into one > > object_type_dictionary[options.object_type]() > > but the first version may be clearer. > > Thanks for your valuable inputs all worked

Re: Python : parsing the command line options using optparse

2014-03-01 Thread Ganesh Pal
On Sat, Mar 1, 2014 at 5:17 PM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > > You should start new threads for new questions. The subject line here has > nothing to do with the questions you ask. > > Sure Steven and thanks for replying and your suggestion for Question 2 (

PEP 8 : Maximum line Length :

2014-05-13 Thread Ganesh Pal
the above line is tool long how do I limit it to 79 character without violating any rules * Module isi_corrupt C: 14,0: Line too long (88/80) W: 19,0: Bad indentation. Found 6 spaces, expected 8 Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Optparse to parsing Suggestions !!

2014-05-30 Thread Ganesh Pal
files --path=/tmp/ --size 1000 Questions : Case 1: # The --path is optional for few for the object type. How do I simulate the below behaviour #python corrupt.py --object=super_block --size=1000 ==> Should work even if --path is not given #pyth

Re: Optparse to parsing Suggestions !!

2014-05-30 Thread Ganesh Pal
On Fri, May 30, 2014 at 7:48 PM, Ganesh Pal wrote: > > Hello Python world , > > > I wanted suggestion on how to modify the below code to help me accomodate > the below two cases > > # Here is the Sample code. > > def main(): > """ ---MAIN--

How to I do this in Python ?

2013-08-16 Thread Ganesh Pal
r(Regular_path) regularfiles = " dd if=/dev/urandom of=file1 count=0 bs=1 seek=10" process_1 = subprocess.Popen(regularfiles, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) My goal is to create various kinds of files like sparse, regular ,directories, hard and sy

Re: How to I do this in Python ?

2013-08-18 Thread Ganesh Pal
Hi Steven , Firstly thanks for responding to the question and also guiding me on how to post the question in the right order ( general to least important order ) Please find the comments >>> inline On Fri, 16 Aug 2013 11:51:32 +0530, Ganesh Pal wrote: > My goal is to create vari

Re: How to I do this in Python ?

2013-08-27 Thread Ganesh Pal
On Mon, Aug 19, 2013 at 12:57 PM, Steven D'Aprano wrote: > On Sun, 18 Aug 2013 22:36:01 +0530, Ganesh Pal wrote: > > > Please find the comments >>> inline > > Please don't do that! > > "Arrows" > are used for quoting in emails. If you prefix

fibonacci series what Iam is missing ?

2015-03-23 Thread Ganesh Pal
Hello team , [root@localhost Python]# cat fibonacci-Sequence-3.py ## Example 2: Using recursion def fib(n): if n == 0: return 0 elif n == 1: return 1 else: return fib(n-1) + fib(n-2) print fib(5) # python fibonacci-Sequence-3.py 5 what Iam I missing in the

Re: fibonacci series what Iam is missing ?

2015-03-24 Thread Ganesh Pal
On Tue, Mar 24, 2015 at 5:41 AM, Steven D'Aprano wrote: > Python does not automatically print all return statements. If you want it to > print the intermediate values produced, you will need to add print before > each return: > > > py> def fib(n): > ... if n == 0: > ... result = 0 > .

python : timeit - Tool for measuring execution time

2015-04-21 Thread Ganesh Pal
ython -m timeit 'for i in xrange(100):' ' pass' 10 loops, best of 3: 51.1 msec per loop Iam not able to understand what why only 10 loops were run ? what does this mean and how does this work ? Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Re: python : timeit - Tool for measuring execution time

2015-04-22 Thread Ganesh Pal
Thank you , this answers my question : ) On Apr 22, 2015 6:39 PM, "Michael Torrie" wrote: > > On 04/21/2015 09:31 PM, Ganesh Pal wrote: > > Iam not able to understand what why only 10 loops were run ? what > > does this mean and how does this work ? > >

Ignore stderr and use return code

2015-10-25 Thread Ganesh Pal
cmd, err, ret)) return False - Do I need to add more check to ensure the mount actually succeeds, may be a function? if ret != 0 and check_df_output(): logging.error("Can't run %s got %s (%d)!" % (cmd, err, ret)) Iam using python 2.7 on Linux Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

How to make this simple code look better

2015-10-27 Thread Ganesh Pal
from myPopen import run def configure_network(): """ Prepare network for test """ try: cmd = ("netadm enable -p ncp DefaultFixed") out, err, ret = run(cmd, timeout=60) if ret != "": logging.error("Can't run %s got %s (%d)!" % (cmd, err, ret))

Re: How to make this simple code look better

2015-10-27 Thread Ganesh Pal
> According to the format strings, 'ret' is a number. If that's the case, > it's not a string, so ret != "" will always be true. > > Why are you wrapping the command string literals in (...)? That's not > necessary. > > You're doing the same thing with each of the command strings, so why > not put

Re: How to make this simple code look better

2015-10-27 Thread Ganesh Pal
On Tue, Oct 27, 2015 at 5:38 PM, Tim Chase wrote: > It reduces the redundant code and also brings all of the commands > together in one place to see the expected steps. Thanks your suggested code looks nice , I easily knocked off half the lines of my code :) -- https://mail.python.org/mailman/l

Equal sets with unequal print and str() representations

2011-10-16 Thread Ganesh Gopalakrishnan
#x27;s13', 's2', 's0', 's7', 's6', 's4', 's3', 's14'} S2 = {'s8', 's13', 's2', 's0', 's7', 's6', 's4', 's3', 's14'} >>> S1 S1 {'s8', 's13', 's2', 's0', 's7', 's6', 's4', 's3', 's14'} >>> S2 S2 {'s8', 's3', 's2', 's0', 's7', 's6', 's4', 's13', 's14'} >>> S1==S2 S1==S2 True >>> str(S1) str(S1) "{'s8', 's13', 's2', 's0', 's7', 's6', 's4', 's3', 's14'}" >>> str(S2) str(S2) "{'s8', 's3', 's2', 's0', 's7', 's6', 's4', 's13', 's14'}" >>> str(S1) == str(S2) False -- Ganesh -- http://mail.python.org/mailman/listinfo/python-list

Re: Equal sets with unequal print and str() representations

2011-10-17 Thread Ganesh Gopalakrishnan
ng is because I tend to work within an Emacs inferior shell.) Cheers, Ganesh On 10/16/11 8:23 PM, Ben Finney wrote: Ganesh Gopalakrishnan writes: This probably is known, but a potential pitfall (was, for me) nevertheless. I suspect it is due to hash collisions between 's3' and &#x

Parse multi line with re module.

2012-01-03 Thread Ganesh Kumar
or channel finding device_r = re.compile("^Channel: (\d+)") the two parsing string working. but I want combine two pattern in to one. This is my code http://www.bpaste.net/show/21323/ please guide me . -Ganesh Did I learn something today? If not, I wasted it. -- http://mail.python.

re module help

2012-01-09 Thread Ganesh Kumar
Hi Guys, I have created regular expression with os modules, I have created file sdptool to match the regular expression pattern, will print the result. I want without creating file how to get required output, I tried but i didn't get output correctly, over stream. #! /usr/bin/python import os,re

RE: How to find if a string contains another string

2007-10-29 Thread Borse, Ganesh
erand >>> >>> if smallone in bigstring: ...print 'ok' ... else: ... print 'nok' ... Traceback (most recent call last): File "", line 1, in ? TypeError: 'in ' requires character as left operand Do I need to import any module? Thanks, Ga

How to find if a string contains another string

2007-10-29 Thread Borse, Ganesh
t; Is there any function like "contains" or "exists" in python? What are different alternatives we have? Please help. Thanks and Regards, Ganesh == Please access the attached hyperlink for an impor

How to use the evaluate the code object returned by PyParser_Simp leParseString function?

2007-11-14 Thread Borse, Ganesh
erated by PyParser_SimpleParseString? Do I need to use the "struct _node*" returned by PyParser_SimpleParseString? Any example of this use would be more helpful? Thanks in advance for guidance & help. Warm Regards, Ganesh =

RE: How to evaluate the code object returned by PyParser_SimplePa rseString function?

2007-11-14 Thread Borse, Ganesh
"char*" format. Quit suitable to my need. Can I use the output of the function PyParser_SimpleParseString as input to PyEval_EvalCode? Please guide. Thanks in advance for your time & guidance. Warm Regards, Ganesh -Original Message- From: Gabriel Genellina [mailto:[EMAIL P

What is the function to evaluate code object returned by PyParser _SimpleParseString function?

2007-11-15 Thread Borse, Ganesh
suitable to my need. Can I use the output of the function PyParser_SimpleParseString as input to PyEval_EvalCode? Please guide. Thanks in advance for your time & guidance. Warm Regards, Ganesh -Original Message- From: Gabriel Genellina [mailto:[EMAIL PROTECTED] Sent: 15 Novemb

Re: evaluating object returned by PyParser_SimpleParseString fun ction

2007-11-15 Thread Borse, Ganesh
7;s what I want to know. Regards, Ganesh == Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/d

RE: How to evaluate the code object returned by PyParser_SimplePa rseString function?

2007-11-16 Thread Borse, Ganesh
, Ganesh <[EMAIL PROTECTED]> escribió: > Py_CompileString takes the source code from file, isn't it? > As can be seen from the syntax of this function: PyObject* > Py_CompileString(char *str, char *filename, int start) > > I want to parse the code which is in memory -

How to access C variables in Python code object generated by Py_C ompileString

2007-11-20 Thread Borse, Ganesh
ntaxError: invalid syntax But when I executed the same code in python process, it worked fine. 3) Is this correct use of Py_CompileString, PyEval_EvalCode & Py_BuildValue functions? Please help, guide. Many thanks in advance. Regards, Ganesh //-

PyObject_GetAttrString failing when getting a function pointer fr om PyObject* returned by Py_CompileString

2007-11-20 Thread Borse, Ganesh
es the code successfully. Can we not use the "PyObject*" returned by Py_CompileString as input to PyObject_GetAttrString? What could be wrong? I want to use this function pointer returned by PyObject_GetAttrString as input to PyObject_CallObject. Can I use the "PyObject*"

RE: PyObject_GetAttrString failing when getting a function pointe r fr om PyObject* returned by Py_CompileString

2007-11-20 Thread Borse, Ganesh
> Can we not use the "PyObject*" returned by Py_CompileString as input to > PyObject_GetAttrString? > What could be wrong? >>>per documentation >>>compile string returns None when you use Py_file_input This is not true. I am getting a valid code object returned when I am using "" & Py_file_input.

Compiling python functions on the fly & calling from C++

2007-11-20 Thread Borse, Ganesh
rom file) & then call it many times in the same program? B) How to make sense out of the PyObject* returned by the PyEval_EvalCode function? Thanks in advance for the help. Warm Regards, Ganesh -- PyObject *glb, *loc; glb = PyDict_New(); PyDict_SetItemString

RE: Please help in creating Python function in C ++ program

2007-11-22 Thread Borse, Ganesh
Hi, Yes I agree. After compile() this is "*definition*" of that function. I would like to know, how can we use this code object & call it as a function? May be - how do we convert this Code Object to Function Object to work as Callable Object? Thanks & Regards Ganesh ---

Question on compiled code when embedding Python in C++

2007-12-03 Thread Borse, Ganesh
When we compile a Python code using functions such as Py_CompileString or any other similar compile function, what will be the resulting executable code? Will it be byte code somewhat like the byte code of Java? Or it will be the same binary code like the once generated by C/C++ compilers from th

PyImport_ImportModule("cStringIO") failure with undefined symbol

2008-01-10 Thread Borse, Ganesh
Hi, Can you please guide me for the following problem? The call to "PyImport_ImportModule("cStringIO");" is failing with an error of "undefined symbol: PyObject_SelfIter". Before importing this module, I am importing only the sys module. Py_SetProgramName("/usr/bin/python"); Py_Initialize(

How to read fonts in python

2008-11-17 Thread ganesh gajre
Hello all, I am writing a program to convert indic true type font to unicode. For which i need to know how to read the any file i.e Text, Doc, Excel file in python and identify the font used in which that file is written. So that using Map file can convert the file in unicode. Ginovation. -- http

How to read space separated file in python?

2008-11-21 Thread ganesh gajre
Hi all, I want to read file which is mapping file. Used in to map character from ttf to unicode. eg Map file contain data in the following way: 0 ० 1 १ 2 २ 3 ३ 4 ४ 5 ५ 6 ६ 7 ७ 8 ८ 9 ९ Like this. Please use any unicode editor to view the text if it not properly shown. Now i want to read both th

Re: How to read space separated file in python?

2008-11-21 Thread ganesh gajre
Hey Steve and Joe , Thank you very much. There is yet little problem. But sure all the Pythonist will help me in that. Ginovation, "Every thing is impossible unless you make it possible" On Sat, Nov 22, 2008 at 5:10 AM, Steve Holden <[EMAIL PROTECTED]> wrote: > Joe Strout wrote: > [...] > > Par

Error: invalid multibyte sequence

2009-03-06 Thread ganesh gajre
Hello all, I am trying to use gettext method for my one of program making i18N usable in Unicode. When i enter the text repalcement in .po file and try to create .mo file from that, it gives me error as : invalid multibyte sequence. I tried this for french language. e.g #: pywine.py:121

Python GUI Tkinter Button arrangement

2011-02-15 Thread Ganesh Kumar
up.. all are working but one buttons are top of the screen. i want button in bottom of the frame plz. help me.. this my source code Source Code http://pastebin.com/Lm5teAtS Thanks in Advance -Ganesh. -- Did I learn something today? If not, I wasted it. -- http://mail.python.org/mailman

Python-os. Command Execution

2011-02-19 Thread Ganesh Kumar
) & root.destroy Control will the transferred to the other-window, "top" closed means application will be closed.. plz..help me.. I checked also the command as background process.. like os.system("top &") & root.destroy Advance thanks Regards Ganesh. -- Did I lear

PY-Tkinter Title Bar Icon

2011-02-22 Thread Ganesh Kumar
Hai.. I am new to python Tkinter..I want Title Bar Icon.. plz..Guide me to set up icon in Title Bar. Advance Thanks Thanks -Ganesh. -- Did I learn something today? If not, I wasted it. -- http://mail.python.org/mailman/listinfo/python-list

Python - decode('hex')

2017-02-20 Thread Ganesh Pal
ix this in program 2 ? for my eyes there doesn't look any difference . question 2: I am using the variable newdata because I can't hardcore the value , I have to keep changing this every time the function is called, will return it as a string help me slove this problem def get_data() : return str(data) new_data =get_data(input) Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Re: Python - decode('hex')

2017-02-20 Thread Ganesh Pal
On Feb 21, 2017 12:17 AM, "Rhodri James" wrote: On 20/02/17 17:55, Ganesh Pal wrote: > 1. The only difference between both the programs the difference are just > the below lines. > > newdata = '64000101057804'.decode('hex') > >

Re: Python - decode('hex')

2017-02-20 Thread Ganesh Pal
Got it , MRAB, Thanks for the explanation it was such a simple thing I was breaking my head over it On Tue, Feb 21, 2017 at 1:34 AM, MRAB wrote: > On 2017-02-20 19:43, Ganesh Pal wrote: > >> On Feb 21, 2017 12:17 AM, "Rhodri James" wrote: >> >> On 20/02/1

If statement with or operator

2017-02-22 Thread Ganesh Pal
r , please suggest. I am on Linux and Python 2.7 Regards. Ganesh -- https://mail.python.org/mailman/listinfo/python-list

C-Python and Endianness

2017-03-25 Thread Ganesh Pal
10 e0 01 04 00 01 00 00 00 02 00 00 00 00 00 00 00 || After : 0010 23 51 34 12 ef cd ab 00 02 00 00 00 00 00 00 00 |#Q4.....| ==> 1. I am on a little endian machine and is there a way that I can stop this translation and write the values as it ( looks like we are swapping the bytes )? 2. The value passed i.e op_value is a string and its getting printed correctly at C layer,my value is always a hex decimal string of size 14 or 7 bytes. 3. Is there something that I can take care in python layer to avoid this swap ? Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Basic Nested Dictionary in a Loop

2017-04-02 Thread Ganesh Pal
7;emp_01': {0: {'grade': 'A', 'status': 'single', 'payment': 100, 'exp': '4', 'sex': 'f'}, 1: {'grade': 'A', 'status': 'single', 'payment': 200, 'exp': '4', 'sex': 'f'}, 2: {'grade': 'A', 'status': 'single', 'payment': 400, 'exp': '4', 'sex': 'f'}, 3: {'grade': 'A', 'status': 'single', 'payment': 500, 'exp': '4', 'sex': 'f'}}} >>> Any other suggestion , Please let me know I am on python 2.7 and Linux Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Re: Basic Nested Dictionary in a Loop

2017-04-02 Thread Ganesh Pal
'grade': 'A', > 'payment': 200, > 'sex': 'f', > 'status': 'single'}, > 'salary5': {'exp': '4', > 'grade': 'A', > 'payment': 400, > 'sex': 'f', > 'status': 'single'}, > 'salary6': {'exp': '4', > 'grade': 'A', > 'payment': 500, > 'sex': 'f', > 'status': 'single'}}} > > > > Thanks ; Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Re: Basic Nested Dictionary in a Loop

2017-04-02 Thread Ganesh Pal
> > > Whenever you feel the urge to write range(len(whatever)) -- resist that > temptation, and you'll end up with better Python code ;) > > Thanks for this suggestion but for my better understanding can explain this further even Steve did point the same mistake. > > Instead of artificially blow

Re: Basic Nested Dictionary in a Loop

2017-04-04 Thread Ganesh Pal
Thanks Peter , Terry and others ! On Tue, Apr 4, 2017 at 12:11 PM, Peter Otten <__pete...@web.de> wrote: > Ganesh Pal wrote: > > >> > >> > >> Whenever you feel the urge to write range(len(whatever)) -- resist that > >> temptation, and you'll e

Optimize this code further

2017-04-04 Thread Ganesh Pal
same and I am supposed to retain the same directory structure and logging Here is what I plan to do : 1. Use dictionary and Change testcases variable as dictionary and let its key store the subtest cases , so we have a nested dictionary testcase = {} testcase[‘Test_inode_1’] = createTestCases(LOG_DIR) 2.Since I need to retain the same logging directory structure , maybe I should try to get the key first and then append it to the log file Question : 1. Any other simple tips and tricks to solve the problem , I am a Linux user using python 2.7 Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

match.groupdict() into a single dict

2017-04-19 Thread Ganesh Pal
o add these element {'Block': '1,0,17080320:8192'} , {'p_owner': '1:0070:001a::HEAD'} ... etc to new dictionary (b) or some better regex may be the for loop is not needed and complied pattern can be better. I am a Linux user and on Python 2.7 , Thanks in advance :) Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Re: match.groupdict() into a single dict

2017-04-20 Thread Ganesh Pal
way to escape * ? > /tmp/final_01.py(17)() -> pattern = '(%s)*' % '|'.join(subpattern) (Pdb) n > /tmp/final_01.py(18)() -> match = re.search(pattern, line) (Pdb) pattern '((|?|P|<|B|l|o|c|k|>|(|\\|d|+|,|\\|d|+|,|\\|d|+|:|\\|d|+|)|))*' (Pdb) n error: error('n...repeat',) Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Re: match.groupdict() into a single dict

2017-04-20 Thread Ganesh Pal
)*' % '|'.join(subpatterns) match = re.search(pattern, line) print ' ', match.groupdict() Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

any suggestion on this code

2017-04-23 Thread Ganesh Pal
name__ == '__main__': main() *Sample o/p:* yy-1# python stack1.py {'real_owner': '1:0120', 'fake_owner': 'ab', 'Block': '31115674'} Matching owner found Couple of question here : 1. Any better suggestion to optimize the code and any other observations around use of assert, generators and are exception handled correctly in return_matched_owner() Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Better Regex and exception handling for this small code

2017-07-11 Thread Ganesh Pal
].strip() logging.info("checksumbefore :%s and checksumafter:%s" % (checksumbefore, checksumafter)) if checksumbefore == checksumafter: raise Exception("checksum not macthing") I am on Linux and Python 2.7 Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Re: Better Regex and exception handling for this small code

2017-07-11 Thread Ganesh Pal
I am trying to open a file and check if the pattern i.e initiator_crc has changed after the task got completed? * On Tue, Jul 11, 2017 at 10:01 PM, Ganesh Pal wrote: > Dear Python friends > > I am trying to open a file and check if there is a pattern has changed > after

Re: Better Regex and exception handling for this small code

2017-07-18 Thread Ganesh Pal
Thanks Cameron Simpson for you suggestion and reply quite helpful :) On Wed, Jul 12, 2017 at 5:06 AM, Cameron Simpson wrote: > On 11Jul2017 22:01, Ganesh Pal wrote: > >> I am trying to open a file and check if there is a pattern has changed >> after the task got complete

Best way to assert unit test cases with many conditions

2017-07-18 Thread Ganesh Pal
not fixed \n" 51 52 if not library.is_corruption_reparied(): 53 assert False, "Corruption not reported,fixed and auto repaired.\n" 54 55 @classmethod 56 def tearDownClass(self): 57 """ Delete all files """ 58 os.system("rm -rf /tmp/files/") 59 60 if __name__ == '__main__': 61 unittest.main() I am a Linux user with Python 2.7. Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Re: Best way to assert unit test cases with many conditions

2017-07-19 Thread Ganesh Pal
if not library.is_corruption_reparied(): 41 assert False, "Corruption not reported,fixed and auto repaired.\n" 42 Let me know if it isn't clear I can give you more examples , Thanks for responding Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Re: Best way to assert unit test cases with many conditions

2017-07-19 Thread Ganesh Pal
# Then pass test_this() and don't run next test i.e. sub_test_4() ,sub_test_5(). etc) Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Tips to match multiple patterns from from a single file .

2017-07-23 Thread Ganesh Pal
x = m.group().split() print filename , x[-1] x123-45# python test.py /var/01010101/test01_.log 1,1,25296896:8192 I am on Python 2.7 and Linux Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

unpacking elements in python - any tips u want to share ?

2017-07-27 Thread Ganesh Pal
code using slices, >>my_list[] 1 4094 2 4th element 5th element 2 4094 01 >>> my_list[-2] 4094 >>> my_list[1] 4094 >>var1 = my_list[-2] >> var 2 = my_list[1] >>> if len(my_list) == 8: ...if my_list[-2] == my_list[1]: ... pr

Multiple try expect in a for loop

2017-08-22 Thread Ganesh Pal
sys.stderr.write('Unable to open or append Queue %s: %s\n' % (q_name, str(e))) return False return True Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list

<    1   2   3   >