Allowing only one instance of a script?

2005-06-22 Thread Ali
Hi,

I have a script which I double-click to run. If i double-click it
again, it will launch another instance of the script.

Is there a way to allow only one instance of a script, so that if
another instance of the script is launched, it will just return with an
error.

Thanks

Regards,
Ali

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


Re: more newbie list questions

2005-07-14 Thread Ali
It's not really clear what you mean?

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


Re: more newbie list questions

2005-07-14 Thread Ali
sTemplate.replace() returns a string with that substitution.

so you need to reassign it such as:
sTemplate =  sTemplate.replace('author1', author1)

Anyway, Sion Arrowsmith above showed you a much better technique of
filling all those values at once.

Hope this helps,

Ali

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


PYGTK, Google Suggest-like GUI

2005-03-02 Thread Ali
Hi there,

I am using pygtk, and i am implementing a "find as you type" in a text
entry. I intend for it to behave like the 'google suggest' box. So,
that as you type, a list of values appear below the text box as in a
list and you can use arrow keys to select a value.

I can't think of a straight-forward way of doing this with pygtk. Do i
have to put a listbox behind the textbox and make it appear and
disappear?

Is there a better way of doing this?

Thanks...

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


Re: PYGTK, Google Suggest-like GUI

2005-03-03 Thread Ali
I guess what i am looking for is auto-completion but with a drop-down
list...

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


Re: PYGTK, Google Suggest-like GUI

2005-03-03 Thread Ali
Oh well, the cool guys of GTK have just the thing i wanted called
EntryCompletion.
Here's the link in case someone else stumbles over here:

http://www.pygtk.org/pygtk2tutorial/sec-EntryCompletion.html

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


Newbie: A very basic problem related to cgi.py

2004-12-20 Thread Ali
Hello all,

I have got a very simple python code:
___

#!/usr/bin/python
import cgi

def main():
print "Content-type: text/html\n"
form = cgi.FieldStorage()
if form.has_key("firstname") and form["firstname"].value != "":
print "Hello", form["firstname"].value, ""
else:
print "Error! Please enter first name. "

main()
__

I try to run this form the command line (I am on linux) just to check
it out and it gives me the following errors/output:
__

Content-type: text/html
Traceback (most recent call last):
File "./mycgi.py", line 2, in ?
import cgi
File "/usr/lib/python2.3/cgi.py", line 12, in ?
"""Support module for CGI (Common Gateway Interface) scripts.
File "/usr/lib/python2.3/cgi.py", line 6, in main
# scripts, and /usr/local/bin is the default directory where Python
is
AttributeError: 'module' object has no attribute 'FieldStorage'
__

Is it reasonable to infer from the above that cgi.py module has been
loaded successfully? because if it is, why on earth am i getting the
error for FieldStorage??

I think i am missing something very basic here... plese enlighten...
Thanks

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


Re: Newbie: A very basic problem related to cgi.py

2004-12-20 Thread Ali
Okay, i don't know what the problem is...

I ran python in interactive mode and tried "import cgi.py" and i got
the same error... 

Any ideas?

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


Re: Newbie: A very basic problem related to cgi.py

2004-12-20 Thread Ali
You are right, I had first named my file cgi.py... but then i realized
that it was causing conflicts so i renamed it to mycgi.py as you can
see in the trace, but the problem persisted...

After reading your reply i took a look at the directory i was in and
there was a pyc file in it... cgi.pyc, i removed it and it worked!
Thanks for the reply, it pointed me in the right direction...

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


Re: Newbie: A very basic problem related to cgi.py

2004-12-20 Thread Ali
>1. When you tried "import cgi.py" from the interactive prompt,
>was that really what you typed? Because that's not a valid
>import statement for the cgi module. You should have done
>"import cgi" instead.

import cgi was giving me the same error, because it was importing from
the cgi.pyc?

>3. There's something strange about that traceback, I
>think. Why does it show the doc-string for the module,
>and why does it show a comment after the "line 6" line?
>Did you hand-edit this before posting it?

nope, i didn't edit anything...

> maybe of the forehead-slapping kind.
Thanks for the reply, yes it was :)

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


MessageBox ONOK?

2005-04-19 Thread Ali
Hi,

How do i connect the onOK of a win32ui MessageBox with the Ok button so
that I get to know when the user clicks the Ok button?

Regards,
Ali

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


Problem with wxPython

2007-06-26 Thread Ali
Hi

I'm not sure if this is the right place to post, pardon me if it's not.
I'm having a problem with an application written with wxpython. The frame
seems only to refresh when moving my mouse of it, though i frequently call:
frame.Refresh(True). In fact, that line is called by another thread, right
after having modified some of the frames attributes.

here are some snippets of code :
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
self.queue=Queue.Queue(0)
# begin wxGlade: MyFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
iconFile = "gnobots2.xpm"
icon1 = wx.Icon(iconFile, wx.BITMAP_TYPE_XPM)
self.SetIcon(icon1)
self.panel_1 = wx.Panel(self, -1)
self.panel_1.Bind(wx.EVT_PAINT, self.on_paint) 
self.static_line_1 = wx.StaticLine(self, -1)
self.text_ctrl_1 = 
wx.TextCtrl(self, -1, 
"",style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_WORDWRAP)

self.__set_properties()
self.__do_layout()
# end wxGlade
def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
self.SetTitle("Simulation")
self.SetSize((600, 400))
self.static_line_1.SetBackgroundColour(wx.Colour(0, 0, 0))
self.text_ctrl_1.SetMinSize((600, 100))
# end wxGlade

self.blues = []

def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
sizer_1.Add(self.static_line_1, 0, wx.EXPAND, 0)
sizer_1.Add(self.text_ctrl_1, 0, wx.ADJUST_MINSIZE, 0)
self.SetAutoLayout(True)
self.SetSizer(sizer_1)
self.Layout()
# end wxGlade

def on_paint(self, event):
dim = self.panel_1.GetSize()
dc = wx.PaintDC(self.panel_1)
total_types = len(Parameters.DEMANDERS_NUMBERS)
large = dim[1] / (total_types + 3)
long = dim[0] / Parameters.NUMBER_OF_BLUES - 1
for type in range(total_types):
counter = long
for blue in self.blues:
green = (int(blue.biais[type])) * 20
red = - green
if red<0:
red=0
if green<0:
green=0
color = wx.Colour(red, green, 75)
dc.SetPen(wx.Pen(color,long))
dc.DrawLine(counter,50 + (type * (20 +
large)),counter, 50 + large + (ty
pe * (20 + large)))
counter += long
while(not self.queue.empty()):
self.text_ctrl_1.AppendText(str(self.queue.get()) + "\n")


# end of class MyFrame

class MyApp( wx.App):
def OnInit(self):
self.text = ""
self.frame = MyFrame(None , -1, 'Frame Window Demo') 
self.frame.Show(True) 
self.SetTopWindow(self.frame) 
return True
#this is called by an external thread
def paint(self, blues):
self.frame.blues = blues
self.frame.Refresh(True)



I don't know if that is enough information, feel free to ask for more.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to create a single executable of a Python program

2007-07-25 Thread Ali
On Jul 25, 7:34 am, NicolasG <[EMAIL PROTECTED]> wrote:
> Dear fellows,
>
> I'm trying to create a executable file using py2exe . Unfortunately
> along with the python executable file it also creates some other files
> that are needed in order to the executable be able to run in a system
> that doesn't have Python installed. Can some one guide me on how can I
> merge all this files created by py2exe in a single exe file ? If I
> have a python program that uses an image file I don't want this image
> file to be exposed in the folder but only to be accessible through the
> program flow..
>
> Regards,
> Nicolas.

Hi,

I know this is not exactly what you asked for, but if you want a
single exe installer, then take a look at something like Inno Setup.
http://www.jrsoftware.org/isinfo.php

It will package all that stuff into a single exe which Windows users
seem happy to click-and-install.

I blogged the process I use here:
http://unpythonic.blogspot.com/2007/07/pygtk-py2exe-and-inno-setup-for-single.html
(though this has some PyGTK specifics)

Ali

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


Re: Comparing Dictionaries

2007-07-27 Thread Ali
On Jul 26, 10:18 pm, Kenneth Love <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am new to Python, but not programming.  I would like to start my
> Python career by developing programs according to the "best practices"
> of the industry.  Right now, that appears to be unit tests, patterns,
> and source code control.

I am not sure about "best", but one of my "favourite practices" is to
not re-write code that other people have written, and have released
under licenses that allow you to do anything with it.

> So, I am trying to write a unit test for some code that reads a Windows
> style INI file and stores the section, key, and values in a dictionary

So, in the standard library: http://docs.python.org/lib/module-ConfigParser.html
And if you want a more involved approach: 
http://www.voidspace.org.uk/python/configobj.html

Ali

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


Re: win32 question in Python

2007-07-31 Thread Ali
On Jul 30, 11:49 pm, Brad Johnson <[EMAIL PROTECTED]>
wrote:
> Huang, Shun-Hsien  ercot.com> writes:
>
>
>
> but how do I copy a excel file into
>
> > database table by using Python?
>
> I'm not sure if this helps, but you can access the Excel Automation model very
> easily with:
>
> import win32com.client
>
> x1 = client.Dispatch("Excel.Application")
>
> Now you can use the x1 object to access any of the properties and methods in 
> the
> Excel Automation model.

I have only used this to export data as Excel, but it may fulfill your
needs for importing:

http://sourceforge.net/projects/pyexcelerator/

Ali

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


Re: Assignments and Variable Substitution

2007-08-14 Thread Ali
On Aug 14, 12:45 am, Steve Holden <[EMAIL PROTECTED]> wrote:
> Evan Klitzke wrote:
> > On 8/13/07, brad <[EMAIL PROTECTED]> wrote:
> >> I'd like to do something like this:
>
> >> var = '123'
> >> %s = [], %var

> And why would you want a variable whose name is '123'?

... and thus continues the search for private variables in Python.


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


Re: IDE for Python

2007-08-30 Thread Ali
On Aug 21, 11:00 am, Joel Andres Granados <[EMAIL PROTECTED]>
wrote:
> Hello list:
>
> I have tried various times to use an IDE for python put have always been
> disapointed.
> I haven't revisited the idea in about a year and was wondering what the
> python people
> use.
> I have also found http://pida.co.uk/main as a possible solution.  Anyone
> tried it yet?

PIDA (http://pida.co.uk/), in my humble opinion, is the One True IDE*.

It will embed the editor of your choice, use the version control
system of your choice, and integrate the tools of your choice. In
short, it integrates your development tools into a single environment.
Hence the tag: "One True IDE".

Ali

* Emacs is pretty good at this, but since PIDA can embed Emacs anyway,
and adds features to it...

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


Re: problem with TreeView + ListStore

2007-09-04 Thread Ali
On Sep 4, 10:43 am, Guillermo Heizenreder <[EMAIL PROTECTED]> wrote:
> Hi list
> I'm developing a application for learn pygkt, and I need to know when a
> user selected or clicked one determinate row of my TreeView for shot
> another signal .

Hi,

Well, ignoring the rest of the post, I can tell you that the usual way
of
doing this is to connect the changed signal of the treeview's
selection.

This explains it better than I would:

http://faq.pygtk.org/index.py?req=show&file=faq13.011.htp

Now to complete your actual use case:

def on_selection_changed(selection, *args):
 model, paths = selection.get_selected_rows()
 if paths:
hbox.show()

treeView = gtk.TreeView()
selection = self.treeView.get_selection()
selection.connect('changed', on_selection_changed)

There are some situations where you may want to actually connect the
mouse click event, and we can discuss them further if you require.

I should of course mention kiwi.ui.objectlist.ObjectList. It is an
easier to use abstraction over TreeView, and has helped me in every
situation where I would use a TreeView.


Ali

> Study the tutorial [1] I began to see the explanation that I see in the
> chapter 14.7. TreeView Signal and found one in particular
> "select-cursor-row", but I don't understood  how implementing.
>
> Something like that.
>if user_selected_row:
>   self.hbox_118.show()
>   print "YES"
>
> NOTE: self.hbox_118 = wTree.get_widget("hbox118")
>
> Thank and Regard
>
> [1]http://www.pygtk.org/pygtk2tutorial/sec-TreeViewSignals.html
>
> P/D: my English it to bad, I'm a novice.
> --
> Heizenreder Guillermohttp://code.google.com/u/gheize/


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


Re: Python editor/IDE on Linux?

2007-04-14 Thread Ali
On 14 Apr, 05:48, "Jack" <[EMAIL PROTECTED]> wrote:
> That's a good one. I got to find out what's special with Emacs :)

The users.

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


Re: Bizarre behavior with mutable default arguments

2008-01-02 Thread Ali
On Dec 30 2007, 12:27 am, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:

> In the absence of a better solution, I'm very comfortable with keeping
> the behaviour as is. Unfortunately, there's no good solution in Python to
> providing functions with local storage that persists across calls to the
> function:

...

(4) Instances handle this pretty well, just s/functions/methods/.
-- 
http://mail.python.org/mailman/listinfo/python-list


pymat and Matlab6.5

2008-01-05 Thread ali
i want matlab6.5-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Test if list contains another list

2008-11-16 Thread Ali

Its funny, I just visited this problem last week.

<http://dulceetutile.blogspot.com/2008/11/strange-looking-python-
statement_17.html>

./Ali
--
http://mail.python.org/mailman/listinfo/python-list


Re: Help need with subprocess communicate

2008-06-04 Thread Ali
On Jun 3, 10:04 pm, [EMAIL PROTECTED] wrote:
> I'm trying to perform following type of operation from inside a python
> script.
> 1. Open an application shell (basically a tcl )
> 2. Run some commands on that shell and get outputs from each command
> 3. Close the shell
>
> I could do it using communicate if I concatenate all my commands
> ( separated by newline ) and read all the output in the end. So
> basically I could do following sequence:
> 1. command1 \n command2 \n command 3 \n
> 2. Read all the output
>
> But I want to perform it interactively.
> 1. command1
> 2. read output
> 3. command2
> 4. read output ..
>
> Following is my code:
>
> from subprocess import *
> p2 = Popen('qdl_tcl',stdin=PIPE,stdout=PIPE)
> o,e = p2.communicate(input='qdl_help \n qdl_read  \n
> qdl_reg_group_list ')
>
> Please suggest a way to perform it interactively with killing the
> process each time I want to communicate with it.
>
> Thanks in advance,
> -Rahul.

It sounds like this may help: http://www.noah.org/wiki/Pexpect

(pure python expect-like functionality)

Ali
--
http://mail.python.org/mailman/listinfo/python-list


Detect file is locked - windows

2012-11-13 Thread Ali Akhavan
I am trying to open a file in 'w' mode open('file', 'wb'). open() will throw 
with IOError with errno 13 if the file is locked by another application or if 
user does not have permission to open/write to the file. 

How can I distinguish these two cases ? Namely, if some application has the 
file open or not. 

Thanks,
nomadali
-- 
http://mail.python.org/mailman/listinfo/python-list


How to make PyDev pep8 friendly?

2012-02-08 Thread Ali Zandi
Hi,

I was trying to find a way to configure PyDev e.g. in Eclipse to be
pep8 friendly.

There are a few configurations like right trim lines, use space after
commas, use space before and after operators, add new line at the end
of file which can be configured via Eclipse -> Window -> Preferences -
> PyDev -> Editor -> Code Style -> Code Formatter. But these are not
enough; for example I couldn't find a way to configure double line
spacing between function definitions.

So is there any way to configure eclipse or PyDev to apply pep8 rules
e.g. on each save?

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


Re: solutions books

2012-04-28 Thread ali deli
Hi,




I'am a college physics student.




If you have the following document "

SOLUTIONS MANUAL
  TO FUNDAMENTALS OF ENGINEERING ELECTROMAGNETICS, by

DAVID CHENG ",




Could you please send me the document?
-- 
http://mail.python.org/mailman/listinfo/python-list


Inexplicable behavior in simple example of a set in a class

2011-07-02 Thread Saqib Ali


I have written two EXTREMELY simple python classes. One class
(myClass1) contains a data attribute (myNum) that contains an integer.
The other class (myClass2) contains a data attribute (mySet) that
contains a set.

I instantiate 2 instances of myClass1 (a & b). I then change the value
of a.myNum. It works as expected.

Then I instantiate 2 instances of myClass2 (c & d). I then change the
value of c.mySet. Bizarrely changing the value of c.mySet also affects
the value of d.mySet which I haven't touched at all!?!?! Can someone
explain this very strange behavior to me? I can't understand it for
the life of me.

Please see below the source code as well as the output.


-- SOURCE CODE --
import sets

class myClass1:

myNum = 9

def clearNum(self):
self.myNum = 0

def __str__(self):
  return str(self.myNum)

class myClass2:

mySet = sets.Set(range(1,10))

def clearSet(self):
self.mySet.clear()

def __str__(self):
  return str(len(self.mySet))

if __name__ == "__main__":

# Experiment 1. Modifying values of member integers in two
different instances of a class
# Works as expected.
a = myClass1()
b = myClass1()
print "a = %s" % str(a)
print "b = %s" % str(b)
print "a.clearNum()"
a.clearNum()
print "a = %s" % str(a)
print "b = %s\n\n\n" % str(b)



# Experiment 2. Modifying values of member sets in two different
instances of a class
# Fails Unexplicably. d is not being modified. Yet calling
c.clearSet() seems to change d.mySet's value
c = myClass2()
d = myClass2()
print "c = %s" % str(c)
print "d = %s" % str(d)
print "c.clearSet()"
c.clearSet()
print "c = %s" % str(c)
print "d = %s" % str(d)




-- OUTPUT --
> python.exe myProg.py

a = 9
b = 9
a.clearNum()
a = 0
b = 9



c = 9
d = 9
c.clearSet()
c = 0
d = 0
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inexplicable behavior in simple example of a set in a class

2011-07-02 Thread Saqib Ali
> Instance variables are properly created in the __init__()
> initializer method, *not* directly in the class body.
>
> Your class would be correctly rewritten as:
>
> class MyClass2(object):
>     def __init__(self):
>         self.mySet = sets.Set(range(1,10))
>
>     def clearSet(self):
> # ...rest same as before...


Thanks Chris. That was certainly very helpful!!

So just out of curiosity, why does it work as I had expected when the
member contains an integer, but not when the member contains a set?
-- 
http://mail.python.org/mailman/listinfo/python-list


Hello Sweet Friends.

2011-07-07 Thread Ashraf Ali
I bring you a source of entertaintment.Just visit the following link
and know about Bollywood actresses
www.bollywoodactresseshotpictures.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python-list Digest, Vol 94, Issue 52

2011-07-08 Thread Mapere Ali
Hi,

I need help with a python script to monitor my wireless router
internet usage using a Mac address and then backup the report files on
the server. i would also like to create login access on the website to
have users checkout their bandwidth usage...Please help anyone
I'm a newbie in Python..

Regards
mapere

I'v
On 7/8/11, python-list-requ...@python.org
 wrote:
> Send Python-list mailing list submissions to
>   python-list@python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>   http://mail.python.org/mailman/listinfo/python-list
> or, via email, send a message with subject or body 'help' to
>   python-list-requ...@python.org
>
> You can reach the person managing the list at
>   python-list-ow...@python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Python-list digest..."
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Hello My Sweet Friends.

2011-07-31 Thread Ashraf Ali
Hello Friends.
How are you all?
Please Visit the following link if you know about Pakistan and what
happening in the world.

http://bollywoodactresseshotpictures.blogspot.com/
http://jobopportunitiesinpakistan.blogspot.com/
http://hotfemaletennisplayershotphotos.blogspot.com/
http://watchonlineindianmovies.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Hot Bollwood Actresses and Hot Football Players of Spain Soccer Team

2011-08-26 Thread Ashraf Ali
Hot Bollywood Actresses and Hot Football Players of Spain Nation
Soccer Team.

http://bollywoodactresseshotdresses.blogspot.com/
http://spainnationalfootballteamwallpapers.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Today's Hottest actresses

2011-02-24 Thread Ashraf Ali
Hello friends. Would you like to know about bollywood hot and
beautiful actresses?You can fine a lot of information about bollywood
actresses.Just visit

 www.hotpics00.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Today's Hottest actresses

2011-02-25 Thread Ashraf Ali
Hello friends, what's going on? Would you like to watch hollywood,
bollywood. tollywood, hot actresses pictures,biography, filmography.
Just visit
www.hotpics00.blogspot.com
www.hollywood-99.blogspot.com
www.hollywoodactors-99.blogspot.com
www.bollywoodactors00.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Hello Friends

2011-03-01 Thread Ashraf Ali
It's a suprise.Do you know what the following blog is about.Just visit
to know
www.hotpics00.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Hello Friends

2011-03-01 Thread Ashraf Ali
It's a suprise.Do you know what the following blog is about.Just visit
to know
www.hotpics00.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Hello Friends

2011-03-02 Thread Ashraf Ali
It’s good to be informed of the world.For lattest news just visit
www.newsbeam.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Hello Friends

2011-03-13 Thread Ashraf Ali
If someone want to know about Bollywood Hot actress and the biography,
Just
www.hotpics00.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Hello Friends

2011-03-26 Thread Ashraf Ali
For Biography of Bollywood actresses just visit 
www.hothitsbollywood.blogspot.com
Here Just for You
Aiswarya Rai

Aishwarya Rai Biography
Ash Ash Baby
Aishwarya Krishnaraj Rai was born on 1 November 1973 in Mangalore. Her
father Krishnaraj Rai was a marine engineer and her mother Vrinda Rai
is a writer. She has an older brother Aditya Rai who is in the
merchant navy. He also happened to co-produce Dil Ka Rishta in 2003,
which starred Ash. The family moved to Mumbai where she studied at the
Arya Vidya Mandir and later moved to Ruparel College. She was aspiring
to study architecture but that did not take off while her career in
the glamour industry took off.

Ash won the coveted Miss World crown in 2004. Soon after this she
pledged to donate her eyes after her death. She went on to become the
brand ambassador for brands like L’Oreal, Pepsi, and Coco Cola. She
struck a pose for many international magazines like TIME and was also
voted one of the most attractive and influential women by several
polls. She is the first Indian actor to be part of the jury at the
prestigious Cannes Film Festival. She has appeared in The Oprah
Winfrey Show, Late Show with David Letterman, and 60 Minutes. She was
also the first Indian actress to be replicated in wax at Madame
Tussaud’s Museum in London.

She was briefly involved with actors Salman Khan and Vivek Oberoi
before marrying actor Abhishek Bachchan, son of the iconic Amitabh
Bachchan and Jaya Bachchan. They were married in 2007. The couple have
acted together in many movies. They were seen in the latest Lux ad and
have been roped in to be part of PETA’s Lovebirds campaign.

The Rai Magic
Aishwarya began her career in the film industry with a Tamil film
Iruvar in 1997 which was a hit as opposed to her Hindi film Aur Pyaar
Ho Gaya with Bobby Deol. She won the Filmfare Best Actress Award for
her next Tamil film Jeans, which was also an entry to the Oscars. In
1999, she gained recognition in Bollywood with hits like Taal and Hum
Dil De Chuke Sanam, in which she played opposite Salman Khan and Ajay
Devgan, her role as Nandini fetching her the Filmfare Best Actress
Award.

In 2000, her Tamil film Kandukondain Kandukondain, saw a good turnout.
She took on the role of Shirley, Shahrukh Khan’s sister in Josh and
then played his love interest in Mohabbatein which won her a
nomination for the Filmfare Best Supporting Actress Award. In Hamara
Dil Aapke Paas Hai, she played Preeti Virat, a rape victim and was
considered for the Filmfare Best Actress Award. The year 2001 was a
quiet year for Ash.

Sanjay Leela Bhansali’s Devdas (2002), in which she played Paro with
Shahrukh Khan and Madhuri Dixit, was an instant blockbuster. It also
received a special screening at the Cannes Film Festival. She won the
Filmfare Best Actress award. In 2003, she acted the part of Binodini
in a Bengali film Choker Bali which was based on a novel by
Rabindranath Tagore. The film was nominated for the Golden Leopard at
the Locarno International Film Festival.

The year 2004 saw Ash in her first English film, Gurinder Chaddha’s
Bride & Prejudice, an adaptation of Jane Austen’s Pride & Prejudice.
Her performance as Neerja in Rituparno Ghosh’s Raincoat was praised.
This was followed by her second English film in 2005, The Mistress of
Spices, with Dylan McDermott of The Practice fame. Her dance sequence
Kajra Re from Bunty Aur Babli became one of the most popular tunes of
the year.

She had two films out in 2006. Umrao Jaan with Abhishek Bachchan
failed to do well while Dhoom 2 where she played Sunehri and shared a
‘controversial’ liplock with Hrithik Roshan was a big hit. In 2007,
she played Sujata opposite Abhishek Bachchan in Guru, based on the
industrialist Dhirubhai Ambani and it was successful. Provoked, which
was based on a real episode of domestic violence, won critical
acclaim. The other English film, The Last Legion, did not do so well.

Jodhaa Akbar, released in 2008, in which she acted the part of Jodhaa
Bai with Hrithik Roshan was average. The sequel to Sarkar, Ram Gopal
Varma’s Sarkar Raj, in which she plays a CEO alongside Amitabh
Bachchan and Abhishek Bachchan, is said to be one of her best
performances till date.

In 2009, Rai looked her gorgeous self in The Pink Panther 2 with Steve
Martin.

Going Strong
She was also busy shooting for Mani Ratnam’s Raavan with Abhishek
Bachchan and Endhiran with Rajnikanth in 2009. Both movies will be
released in 2010 along with Action Replay with Akshay Kumar and
Guzaarish, in which she will play Hrithik Roshan’s nurse.
-- 
http://mail.python.org/mailman/listinfo/python-list


Hello Friends

2011-03-30 Thread Ashraf Ali
You can fine Bollywood Actresses Biography, WAllpapers & Pictures on
the following website.
www.bollywoodhotactresses.weebly.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Hello Friends

2011-03-30 Thread Ashraf Ali
you can fine bollywood actresses biography,wallpapers & pictures on
this website
www.bollywoodhotactresses.weebly.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Have a nice day.

2011-04-04 Thread Ashraf Ali
Hello friends.
 What are you looking for. You can find everything
what you want.
just visit: www.hothitsbollywood.blogspot.com
www.aishwaryaraismile.blogspot.com
www.bollywoodhotpik.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Have a nice day.

2011-04-10 Thread Ashraf Ali
Sale Sale Sale. Just visit the following link to buy computer
accessories. You can buy computer accessories on reasonable prices.
just visit
http://www.onlineshoppingpk.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Hello Friends

2011-04-12 Thread Ashraf Ali
The most sexiest collection of bollywood.
just visit
www.hottesthitsbollywood.blogspot.com
www.bollywoodhotactresspicz.blogspot.com
www.bollywoodhotphotoz.blogspot.com
www.bollywoodhotactresswallpapers.blogspot.com
www.bollywoodhotwallpaperz.blogspot.com
www.onlineshoppingpk.blogspot.com
www.bollywoodhotpik.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Have a nice day.

2011-04-16 Thread Ashraf Ali
Just visit and know the basic information about Bollywood actresses.
You can here Biographies of all bollywood Actresses.
www.bollystarsbiographies.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Hello Sweet Friends

2011-04-20 Thread Ashraf Ali
Friends . What are you looking for? Just visit the folowing link and
find what you want
www.spicybollywoodpix.blogspot.com
hothitsbollywood.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Hello Friends

2011-05-02 Thread Ashraf Ali
What are you lookink for. Just visit to see what you want
www.bollywoodhotactresswallpapers.blogspot.com

www.bollywoodhotwallpaperz.blogspot.com

www.bollywoodhotactresspicz.blogspot.com

www.hottesthitsbollywood.blogspot.com

www.bollywoodhotphotoz.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Converting hex data to image

2021-01-31 Thread Ali Sajadian
dimplem...@gmail.com در تاریخ سه‌شنبه ۱۲ مارس ۲۰۱۹ ساعت ۱۳:۰۱:۴۵ (UTC+3:30) 
نوشت:
> On Tuesday, March 12, 2019 at 2:53:49 PM UTC+5:30, Peter Otten wrote: 
> > dimplem...@gmail.com wrote: 
> > 
> > >> Save the image to a file (in binary mode!) and then try to open it with 
> > >> an image viewer. The data may be corrupted. 
> > > 
> > > When i tried doing that it says Invalid Image... 
> > 
> > So it looks like the problem occurs somewhere before you are decoding the 
> > image with the PIL...
> This is what i am doing : 
> for associate in self.conn.response[:-1]: 
> attributes = associate['attributes'] 
> obj = { 
> 'img':attributes['thumbnailPhoto'],} 
> This img i am calling in my view and writing to the file...

Hi could you solve this problem dimplem?
I have exactly the same issue when I read thumbnailPhoto from active directory
-- 
https://mail.python.org/mailman/listinfo/python-list


Convert MBOX thunderbird to PST outlook

2021-02-07 Thread Kr4ck ALI
Hello,

I have to migrate multiple mailbox (emails, contacts, calendar, tasks) from
thunderbird to outlook Office 365.
I plan to export all items from thunderbird files (.mbox for email, .sqlite
or .sdb for calendar, .mab to contact) to PST files and import each PST
files to Office 365.
I know it's a tedious task ... But I know that nothing is impossible !
I found this script very helpfull to begin :

#!python3
import os, sys
import gzip
import mailbox
import urllib.request
import win32com.client

dispatch = win32com.client.gencache.EnsureDispatch
const = win32com.client.constants
PST_FILEPATH =
os.path.abspath(os.path.join(os.path.expandvars("%APPDATA%"),
"scratch.pst"))
if os.path.exists(PST_FILEPATH):
os.remove(PST_FILEPATH)
ARCHIVE_URL =
"https://mail.python.org/pipermail/python-list/2015-November.txt.gz";
MBOX_FILEPATH = "archive.mbox"

def download_archive(url, local_mbox):
with gzip.open(urllib.request.urlopen(url)) as archive:
with open(local_mbox, "wb") as f:
print("Writing %s to %s" % (url, local_mbox))
f.write(archive.read())

def copy_archive_to_pst(mbox_filepath, pst_folder):
archive = mailbox.mbox(mbox_filepath)
for message in archive:
print(message.get("Subject"))
pst_message = pst_folder.Items.Add()
pst_message.Subject = message.get("Subject")
pst_message.Sender = message.get("From")
pst_message.Body = message.get_payload()
pst_message.Move(pst_folder)
pst_message.Save()

def find_pst_folder(namespace, pst_filepath):
for store in dispatch(mapi.Stores):
if store.IsDataFileStore and store.FilePath == PST_FILEPATH:
return store.GetRootFolder()

download_archive(ARCHIVE_URL, MBOX_FILEPATH)
outlook = dispatch("Outlook.Application")
mapi = outlook.GetNamespace("MAPI")
pst_folder = find_pst_folder(mapi, PST_FILEPATH)
if not pst_folder:
mapi.AddStoreEx(PST_FILEPATH, const.olStoreDefault)
pst_folder = find_pst_folder(mapi, PST_FILEPATH)
if not pst_folder:
raise RuntimeError("Can't find PST folder at %s" % PST_FILEPATH)
copy_archive_to_pst(MBOX_FILEPATH, pst_folder)

My question is : Have you already make a mission like that ?

Thanks in advance !

@Kr4ckali
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Convert MBOX thunderbird to PST outlook

2021-02-07 Thread Kr4ck ALI
I have about 1000 mailbox to migrate and all are store in local on each
computers.
I know PST files store contacts, calendar, tasks... So, I think that is
possible to build a PST file with python to integrate the differents items
(emails, calendar, tasks,...) from thunderbird files.


Le lun. 8 févr. 2021 à 00:45, Cameron Simpson  a écrit :

> On 07Feb2021 15:06, Kr4ck ALI  wrote:
> >I have to migrate multiple mailbox (emails, contacts, calendar, tasks)
> >from thunderbird to outlook Office 365.
>
> I am also sorry to hear that.
>
> Had you considered getting them to enable IMAP access? Then you can
> migrate just by moving messages inside Thunderbird. And you can keep
> using your mail reader of choice.
>
> >I plan to export all items from thunderbird files (.mbox for email,
> .sqlite
> >or .sdb for calendar, .mab to contact) to PST files and import each PST
> >files to Office 365.
>
> The contacts and calendar stuff I have less idea about, alas. CalDAV for
> the calendar? I know that's a vague and unspecific suggestion.
>
> Cheers,
> Cameron Simpson 
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


PyQt4

2016-04-03 Thread Muhammad Ali

Hi,

How can we confirm that either  PyQt4 is already installed on LInux machine or 
not?

Please suggest commands to confirm the already existence of  PyQt4 in the 
machine.

Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Plot/Graph

2016-04-03 Thread Muhammad Ali

Hi,

Could anybody tell me that how can I plot graphs by matplotlib and get 
expertise in a short time? I have to plot 2D plots just like origin software. 

Secondly, how could we draw some horizontal reference line at zero when the 
vertical scale is from -3 to 3? 

Looking for your posts, please.

Thank you.

p.s: Is there any short and to the point text book/manual/pdf to learn 2D 
plotting with matplotlib?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt4

2016-04-03 Thread Muhammad Ali
On Sunday, April 3, 2016 at 12:15:06 PM UTC-7, Michael Torrie wrote:
> On 04/03/2016 12:57 PM, Muhammad Ali wrote:
> > 
> > Hi,
> > 
> > How can we confirm that either  PyQt4 is already installed on LInux machine 
> > or not?
> > 
> > Please suggest commands to confirm the already existence of  PyQt4 in the 
> > machine.
> 
> Ideally you make a distribution-specific package of the binary in a .deb
> on Debian or an RPM on other distros, and specify that it depends on the
> package that provides PyQt4.  That way when it's installed, modern
> package managers will automatically install the dependencies.
> 
> Alternatively you can use try and except in your python code to attempt
> to import something from PyQt4 and see if it fails or not.  This
> technique is also used to make your code work either PyQt4 or PySide,
> depending on which the user has installed.
> 
> try:
> from PySide import QtGui
> except ImportError:
> from PyQt4 import QtGui
> 
> If neither are installed, this little example will end with an ImportError.

Thank you for your suggestions. I tried both but it shows the following error:
IndentationError: expected an indented block

Actually, I have to plot some graphs by using matplotlib and PyQt4 at 
supercomputer.

Any other suggestion???
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Plot/Graph

2016-04-03 Thread Muhammad Ali
On Sunday, April 3, 2016 at 2:04:45 PM UTC-7, Michael Selik wrote:
> Indeed there is. Every example in the gallery shows the code to produce it.
> 
> http://matplotlib.org/gallery.html
> 
> On Sun, Apr 3, 2016, 8:05 PM Muhammad Ali 
> wrote:
> 
> >
> > Hi,
> >
> > Could anybody tell me that how can I plot graphs by matplotlib and get
> > expertise in a short time? I have to plot 2D plots just like origin
> > software.
> >
> > Secondly, how could we draw some horizontal reference line at zero when
> > the vertical scale is from -3 to 3?
> >
> > Looking for your posts, please.
> >
> > Thank you.
> >
> > p.s: Is there any short and to the point text book/manual/pdf to learn 2D
> > plotting with matplotlib?
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >

Thank you for your post.

 How do I convert/change/modify python script so that my data could be 
extracted according to python script and at the end it generates another single 
extracted data file instead of displaying/showing some graph? So that, I can 
manually plot the newly generated file (after data extraction) by some other 
software like origin.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Plot/Graph

2016-04-03 Thread Muhammad Ali
On Sunday, April 3, 2016 at 2:35:58 PM UTC-7, Oscar Benjamin wrote:
> On 3 Apr 2016 22:21, "Muhammad Ali"  wrote:
> >
> >  How do I convert/change/modify python script so that my data could be
> extracted according to python script and at the end it generates another
> single extracted data file instead of displaying/showing some graph? So
> that, I can manually plot the newly generated file (after data extraction)
> by some other software like origin.
> 
> It depends what you're computing and what format origin expects the data to
> be in. Presumably it can use CSV files so take a look at the CSV module
> which can write these.
> 
> (You'll get better answers to a question like this if you show us some code
> and ask a specific question about how to change it.)
> 
> --
> Oscar

How could the python script be modified to generate data file rather than 
display a plot by using matplotlib?


def make_plot(plot):
indent = plot.plot_options.indent
args = plot.plot_options.args
# Creating the plot
print ('Generating the plot...')
fig = plt.figure(figsize=(plot.fig_width_inches,plot.fig_height_inches))
ax = fig.add_subplot(111)
# Defining the color schemes.
print (indent + '>>> Using the "' + plot.cmap_name + '" colormap.')
if(plot.plot_options.using_default_cmap and not args.running_from_GUI):
print (2 * indent + 'Tip: You can try different colormaps by either:')
print (2 * indent + ' * Running the plot tool with the option 
-icmap n, ' \
   'with n in the range from 0 to', len(plot.plot_options.cmaps) - 
1)
print (2 * indent + ' * Running the plot tool with the option 
"-cmap cmap_name".')
print (2 * indent + '> Take a look at')
print (4 * indent + 
'<http://matplotlib.org/examples/color/colormaps_reference.html>')
print (2 * indent + '  for a list of colormaps, or run')
print (4 * indent + '"./plot_unfolded_EBS_BandUP.py --help".')

# Building the countour plot from the read data
# Defining the (ki,Ej) grid.
if(args.interpolation is not None):
ki = np.linspace(plot.kmin, plot.kmax, 2 * len(set(plot.KptsCoords)) + 
1, endpoint=True)
Ei = np.arange(plot.emin, plot.emax + plot.dE_for_hist2d, 
plot.dE_for_hist2d)
# Interpolating
grid_freq = griddata((plot.KptsCoords, plot.energies), plot.delta_Ns, 
(ki[None,:], Ei[:,None]), 
 method=args.interpolation, fill_value=0.0)
else:
ki = np.unique(np.clip(plot.KptsCoords, plot.kmin, plot.kmax))
Ei = np.unique(np.clip(plot.energies, plot.emin,  plot.emax))
grid_freq = griddata((plot.KptsCoords, plot.energies), plot.delta_Ns, 
(ki[None,:], Ei[:,None]), 
 method='nearest', fill_value=0.0)

if(not args.skip_grid_freq_clip):
grid_freq = grid_freq.clip(0.0) # Values smaller than zero are just 
noise.
# Normalizing and building the countour plot
manually_normalize_colorbar_min_and_maxval = False
if((args.maxval_for_colorbar is not None) or (args.minval_for_colorbar is 
not None)):
manually_normalize_colorbar_min_and_maxval = True
args.disable_auto_round_vmin_and_vmax = True
maxval_for_colorbar = args.maxval_for_colorbar
minval_for_colorbar = args.minval_for_colorbar
else:
if not args.disable_auto_round_vmin_and_vmax:
minval_for_colorbar = float(round(np.min(grid_freq)))
maxval_for_colorbar = float(round(np.max(grid_freq)))
args.round_cb = 0
if(manually_normalize_colorbar_min_and_maxval or not 
args.disable_auto_round_vmin_and_vmax):
modified_vmin_or_vmax = False
if not args.disable_auto_round_vmin_and_vmax and not 
args.running_from_GUI:
print (plot.indent + '* Automatically renormalizing color scale '\
   '(you can disable this with the option 
--disable_auto_round_vmin_and_vmax):')
if manually_normalize_colorbar_min_and_maxval:
print (plot.indent + '* Manually renormalizing color scale')
if(minval_for_colorbar is not None):
previous_vmin = np.min(grid_freq)
if(abs(previous_vmin - minval_for_colorbar) >= 0.1):
modified_vmin_or_vmax = True
print (2 * indent + 'Previous vmin = %.1f, new vmin = %.1f' % 
(previous_vmin, 
   
minval_for_colorbar))
else:
minval_for_colorbar = np.min(grid_freq)
if(maxval_for_colorbar is not None):
previous_vmax = np.max(grid_freq)
if(abs(previous_vmax

Re: Plot/Graph

2016-04-04 Thread Muhammad Ali
On Sunday, April 3, 2016 at 5:19:15 PM UTC-7, MRAB wrote:
> On 2016-04-04 01:04, Muhammad Ali wrote:
> > On Sunday, April 3, 2016 at 2:35:58 PM UTC-7, Oscar Benjamin wrote:
> >> On 3 Apr 2016 22:21, "Muhammad Ali"  wrote:
> >> >
> >> >  How do I convert/change/modify python script so that my data could be
> >> extracted according to python script and at the end it generates another
> >> single extracted data file instead of displaying/showing some graph? So
> >> that, I can manually plot the newly generated file (after data extraction)
> >> by some other software like origin.
> >>
> >> It depends what you're computing and what format origin expects the data to
> >> be in. Presumably it can use CSV files so take a look at the CSV module
> >> which can write these.
> >>
> >> (You'll get better answers to a question like this if you show us some code
> >> and ask a specific question about how to change it.)
> >>
> >> --
> >> Oscar
> >
> > How could the python script be modified to generate data file rather than 
> > display a plot by using matplotlib?
> >
> >
> > def make_plot(plot):
> >  indent = plot.plot_options.indent
> >  args = plot.plot_options.args
> >  # Creating the plot
> >  print ('Generating the plot...')
> >  fig = 
> > plt.figure(figsize=(plot.fig_width_inches,plot.fig_height_inches))
> >  ax = fig.add_subplot(111)
> >  # Defining the color schemes.
> >  print (indent + '>>> Using the "' + plot.cmap_name + '" colormap.')
> >  if(plot.plot_options.using_default_cmap and not args.running_from_GUI):
> >  print (2 * indent + 'Tip: You can try different colormaps by 
> > either:')
> >  print (2 * indent + ' * Running the plot tool with the option 
> > -icmap n, ' \
> > 'with n in the range from 0 to', 
> > len(plot.plot_options.cmaps) - 1)
> >  print (2 * indent + ' * Running the plot tool with the option 
> > "-cmap cmap_name".')
> >  print (2 * indent + '> Take a look at')
> >  print (4 * indent + 
> > '<http://matplotlib.org/examples/color/colormaps_reference.html>')
> >  print (2 * indent + '  for a list of colormaps, or run')
> >  print (4 * indent + '"./plot_unfolded_EBS_BandUP.py --help".')
> >
> >  # Building the countour plot from the read data
> >  # Defining the (ki,Ej) grid.
> >  if(args.interpolation is not None):
> >  ki = np.linspace(plot.kmin, plot.kmax, 2 * 
> > len(set(plot.KptsCoords)) + 1, endpoint=True)
> >  Ei = np.arange(plot.emin, plot.emax + plot.dE_for_hist2d, 
> > plot.dE_for_hist2d)
> >  # Interpolating
> >  grid_freq = griddata((plot.KptsCoords, plot.energies), 
> > plot.delta_Ns, (ki[None,:], Ei[:,None]),
> >   method=args.interpolation, fill_value=0.0)
> >  else:
> >  ki = np.unique(np.clip(plot.KptsCoords, plot.kmin, plot.kmax))
> >  Ei = np.unique(np.clip(plot.energies, plot.emin,  plot.emax))
> >  grid_freq = griddata((plot.KptsCoords, plot.energies), 
> > plot.delta_Ns, (ki[None,:], Ei[:,None]),
> >   method='nearest', fill_value=0.0)
> >
> >  if(not args.skip_grid_freq_clip):
> >  grid_freq = grid_freq.clip(0.0) # Values smaller than zero are 
> > just noise.
> >  # Normalizing and building the countour plot
> >  manually_normalize_colorbar_min_and_maxval = False
> >  if((args.maxval_for_colorbar is not None) or (args.minval_for_colorbar 
> > is not None)):
> >  manually_normalize_colorbar_min_and_maxval = True
> >  args.disable_auto_round_vmin_and_vmax = True
> >  maxval_for_colorbar = args.maxval_for_colorbar
> >  minval_for_colorbar = args.minval_for_colorbar
> >  else:
> >  if not args.disable_auto_round_vmin_and_vmax:
> >  minval_for_colorbar = float(round(np.min(grid_freq)))
> >  maxval_for_colorbar = float(round(np.max(grid_freq)))
> >  args.round_cb = 0
> >  if(manually_normalize_colorbar_min_and_maxval or not 
> > args.disable_auto_round_vmin_and_vmax):
> >  modified_vmin_or_vmax =

Re: Plot/Graph

2016-04-04 Thread Muhammad Ali
On Sunday, April 3, 2016 at 2:35:58 PM UTC-7, Oscar Benjamin wrote:
> On 3 Apr 2016 22:21, "Muhammad Ali"  wrote:
> >
> >  How do I convert/change/modify python script so that my data could be
> extracted according to python script and at the end it generates another
> single extracted data file instead of displaying/showing some graph? So
> that, I can manually plot the newly generated file (after data extraction)
> by some other software like origin.
> 
> It depends what you're computing and what format origin expects the data to
> be in. Presumably it can use CSV files so take a look at the CSV module
> which can write these.
> 
> (You'll get better answers to a question like this if you show us some code
> and ask a specific question about how to change it.)
> 
> --
> Oscar

Yes, it is complete script and it works well with matplotlib.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Plot/Graph

2016-04-04 Thread Muhammad Ali
On Tuesday, April 5, 2016 at 8:16:22 AM UTC+8, Muhammad Ali wrote:
> On Sunday, April 3, 2016 at 2:35:58 PM UTC-7, Oscar Benjamin wrote:
> > On 3 Apr 2016 22:21, "Muhammad Ali"  wrote:
> > >
> > >  How do I convert/change/modify python script so that my data could be
> > extracted according to python script and at the end it generates another
> > single extracted data file instead of displaying/showing some graph? So
> > that, I can manually plot the newly generated file (after data extraction)
> > by some other software like origin.
> > 
> > It depends what you're computing and what format origin expects the data to
> > be in. Presumably it can use CSV files so take a look at the CSV module
> > which can write these.
> > 
> > (You'll get better answers to a question like this if you show us some code
> > and ask a specific question about how to change it.)
> > 
> > --
> > Oscar
> 
> Yes, it is complete script and it works well with matplotlib.

But I have to modify it to extract data into a single .dat file instead of 
directly plotting it by using matplotlib. I want to plot the data file in some 
other software.
-- 
https://mail.python.org/mailman/listinfo/python-list


python script for .dat file

2016-04-05 Thread Muhammad Ali

Hello,

Could any body tell me a general python script to generate .dat file after the 
extraction of data from more than 2 files, say file A and file B?

Or could any body tell me the python commands to generate .dat file after the 
extraction of data from two or more than two files?

I have to modify some python code.

Looking for your valuable posts.

Thank you.

Ali
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python script for .dat file

2016-04-05 Thread Muhammad Ali
On Tuesday, April 5, 2016 at 8:30:27 AM UTC-7, Joel Goldstick wrote:
> On Tue, Apr 5, 2016 at 11:23 AM, Muhammad Ali
>  wrote:
> >
> > Hello,
> >
> > Could any body tell me a general python script to generate .dat file after 
> > the extraction of data from more than 2 files, say file A and file B?
> >
> > Or could any body tell me the python commands to generate .dat file after 
> > the extraction of data from two or more than two files?
> >
> > I have to modify some python code.
> >
> > Looking for your valuable posts.
> >
> > Thank you.
> >
> > Ali
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> 
> What exactly is a .dat file? and how is it different from any other
> file? Is it binary or text data?
> 
> 
> -- 
> Joel Goldstick
> http://joelgoldstick.com/blog
> http://cc-baseballstats.info/stats/birthdays

It is text data.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python script for .dat file

2016-04-05 Thread Muhammad Ali
On Tuesday, April 5, 2016 at 9:07:54 AM UTC-7, Oscar Benjamin wrote:
> On 5 April 2016 at 16:44, Muhammad Ali  wrote:
> > On Tuesday, April 5, 2016 at 8:30:27 AM UTC-7, Joel Goldstick wrote:
> >> On Tue, Apr 5, 2016 at 11:23 AM, Muhammad Ali
> >>  wrote:
> >> >
> >> > Could any body tell me a general python script to generate .dat file 
> >> > after the extraction of data from more than 2 files, say file A and file 
> >> > B?
> >> >
> >> > Or could any body tell me the python commands to generate .dat file 
> >> > after the extraction of data from two or more than two files?
> >> >
> >> > I have to modify some python code.
> >>
> >> What exactly is a .dat file? and how is it different from any other
> >> file? Is it binary or text data?
> >
> > It is text data.
> 
> You haven't provided enough information for someone to answer your
> question. This is a text mailing list so if a .dat file is text then
> you can paste here an example of what it would look like. What would
> be in your input files and what would be in your output files? What
> code have you already written?
> 
> If the file is large then don't paste its entire content here. Just
> show an example of what the data would look like if it were a smaller
> file (maybe just show the first few lines of the file).
> 
> Probably what you want to do is easily achieved with basic Python
> commands so I would recommend to have a look at a tutorial. There are
> some listed here:
> https://wiki.python.org/moin/BeginnersGuide/NonProgrammers
> 
> Also the tutor mailing list is probably more appropriate for this
> level of question:
> https://mail.python.org/mailman/listinfo/tutor
> 
> --
> Oscar

Input and outout files are text files. e.g: 
#KptCoord #E-E_Fermi #delta_N
  0.  -22.   0.000E+00
  0.0707  -22.   0.000E+00
  0.1415  -22.   0.000E+00
  0.2122  -22.   0.000E+00
  0.2830  -22.   0.000E+00
  0.3537  -22.   0.000E+00
  0.4245  -22.   0.000E+00
  0.4952  -22.   0.000E+00
  0.5660  -22.   0.000E+00
  0.6367  -22.   0.000E+00
  0.7075  -22.   0.000E+00
  0.7782  -22.   0.000E+00
  0.8490  -22.   0.000E+00
  0.9197  -22.   0.000E+00
  0.9905  -22.   0.000E+00
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python script for .dat file

2016-04-05 Thread Muhammad Ali
On Tuesday, April 5, 2016 at 2:24:02 PM UTC-7, Joel Goldstick wrote:
> On Tue, Apr 5, 2016 at 4:47 PM, Mark Lawrence via Python-list
>  wrote:
> > On 05/04/2016 21:35, Michael Selik wrote:
> >>
> >> What code have you written so far?
> >>
> >
> > Would you please not top post on this list, it drives me nuts!!!
> >
> >
> A short drive? ;)


> 
> -- 
> Joel Goldstick
> http://joelgoldstick.com/blog
> http://cc-baseballstats.info/stats/birthdays


Would any one paste here some reference/sample python code for such extraction 
of data into text file?
-- 
https://mail.python.org/mailman/listinfo/python-list


Self Learning Fortran Programming

2016-05-31 Thread Muhammad Ali

Hello, 

I am interested in Python programming, however, it will be my first serious 
attempt towards coding/simulation/programming. My back ground is Physics, no 
practical experience with programming languages. 

So, this post is for the valuable suggestions from the experts that how can I 
start self learning Python from scratch to advanced level in minimum time. For 
this, please recommend Python version, literature, text books, websites, video 
lectures, your personnel tips, etc. In addition, you may also add some extra 
suggestions for shell script writing as well. You may recommend for both Linux 
and Windows operating systems. 

Looking for your posts. 

Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Self Learning Fortran Programming

2016-06-01 Thread Muhammad Ali

I don't know how to change the title now, but I am looking for python.
-- 
https://mail.python.org/mailman/listinfo/python-list


Python on Windows with linux environment

2016-06-02 Thread Muhammad Ali

Hi,

I use windows regularly, however, I use linux for only my research work at 
supercomputer. In my research field (materials science) most of the scripts are 
being written in python with linux based system. Could I installed such linux 
based python on my window 7? So that I can use those linux based scripts 
written in python and I can also write my own scripts/code without entirely 
changing my operating system from windows to linux.

Looking for your valuable suggestions.

Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python on Windows with linux environment

2016-06-02 Thread Muhammad Ali
On Friday, June 3, 2016 at 6:27:50 AM UTC+8, Eric S. Johansson wrote:
> On 6/2/2016 2:03 PM, Joel Goldstick wrote:
> > Although the OP is using Windows 7, according to recent articles,
> > Ubuntu is teaming with MS for Windows 10 to include a bash shell,
> > presumably with the package management of Ubuntu (debian), with pip
> > goodness and virtualenv and virtualenvwrapper.  That route should make
> > W10 and linux (ubuntu) nearly identical environments to deal with
> 
> had forgotten about that.  it should be released end of july and I am
> looking forward to the update! in the meantime, I'm suffering with
> cygwin :-)


Please send me the link through which I can get regular updates about this new 
release.
-- 
https://mail.python.org/mailman/listinfo/python-list


DbfilenameShelf instance has no attribute 'writeback'

2005-01-20 Thread warren ali
Anyone have any idea why this is failing with the following error

class _IndexFile:
"""An _IndexFile is an implementation class that presents a
Sequence and Dictionary interface to a sorted index file."""

def __init__(self, pos, filenameroot):
self.pos = pos
self.file = open(_indexFilePathname(filenameroot), _FILE_OPEN_MODE)
self.offsetLineCache = {}   # Table of (pathname, offset) -> (line,
nextOffset)
self.rewind()
self.shelfname = os.path.join(WNSEARCHDIR, pos + ".pyidx")
try:
import shelve
self.indexCache = shelve.open(self.shelfname, 'r')
except:
pass

Exception exceptions.AttributeError: "DbfilenameShelf instance has no
attribute 'writeback'" in Exception exceptions.AttributeError:
"DbfilenameShelf instance has no attribute 'writeback'" in Exception
exceptions.AttributeError: "DbfilenameShelf instance has no attribute
'writeback'" in Exception exceptions.AttributeError: "DbfilenameShelf
instance has no attribute 'writeback'" in

The code still returns the correct restults but each result come back
with this exception.

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


Python Scripting

2005-01-22 Thread Ali Polatel
  Hi Dear Python programmers,
  I want to ask you a question about python scripting.I want to know if I can design web-pages with python or at least write html files with python. and if I write html files with python and some CGI scripts and upload them to the web-page .. does the people who view those pages have to have python interpreters in their computers?
  Another question is ... I am writing a bot for a chess server in python and this bot should update a web-page when it gets some commands from the server.How can i make a programme update a web-page?
  Thanks and regards
		Do you Yahoo!? 
Yahoo! Search presents - Jib Jab's 'Second Term'-- 
http://mail.python.org/mailman/listinfo/python-list

on the way to find pi!

2005-01-23 Thread Ali Polatel

dear friends ,
I found a code which calculates pi with an interesting algorithm the programme code is below:
from sys import stdout
def f((q,r,t,k)):    n = (3*q+r) / t    if (4*q+r) / t == n:    return (10*q,10*(r-n*t),t,k,n)    else:    return (q*k, q*(4*k+2)+r*(2*k+1),t*(2*k+1),k+1)
# Call pi(20) for first 20 digits, or pi() for all digitsdef pi(n=-1):    printed_decimal = False    r = f((1,0,1,1))    while n != 0:    if len(r) == 5:    stdout.write(str(r[4]))    if not printed_decimal:    stdout.write('.')    printed_decimal = True    n -= 1    r = f(r[:4])    #stdout.write('\n')
if __name__ == '__main__':    from sys import argv    try:    digit_count = long(argv[1])    except:    digit_count=int(raw_input('How many digits? :'))    pi(digit_count)    
This code gives the number in an unusual format like "3.1415'None'" it has a number part and a string part . I want to seperate these from easc other but I couldn't manage. I mean when I try to turn it into string format then try to use things like [:4] or like that they don't work.Any idea how to seperate this 'None' from the number and make it a real normal number on which I can do operations like +1 -1 or like that :)
Regards__Do You Yahoo!?Tired of spam?  Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- 
http://mail.python.org/mailman/listinfo/python-list

Re: on the way to find pi!

2005-01-23 Thread Ali Polatel
that's just little near to pi... pi is so far away ;)__Do You Yahoo!?Tired of spam?  Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- 
http://mail.python.org/mailman/listinfo/python-list

Re: on the way to find pi!

2005-01-23 Thread Ali Polatel
write the code type str(pi(5)) and see what I mean__Do You Yahoo!?Tired of spam?  Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- 
http://mail.python.org/mailman/listinfo/python-list

Re: on the way to find pi!

2005-01-24 Thread Ali Polatel
when we change the code that way the programme gets awful slow when I want to calculate say 100 digits or more .Can't we just get the numbers out of there without changing the code radically thus not making the programme sloww?
		Do you Yahoo!? 
Yahoo! Search presents - Jib Jab's 'Second Term'-- 
http://mail.python.org/mailman/listinfo/python-list

Proxy

2005-01-29 Thread Ali Polatel
is it possible to connect to somewhere through a proxy while using sockets module of Python to connect? If yes can you show me some basic examples?
regards
		Do you Yahoo!? 
Yahoo! Search presents - Jib Jab's 'Second Term'-- 
http://mail.python.org/mailman/listinfo/python-list

Programming challenge (C++ and Python)

2005-02-01 Thread Ali Polatel
    Dear Python friends,
    I need a favor.I play chess at a chess server with the name ICC(www.chessclub.com). I want to write a plugin for their interface using Python.
    I don't have any idea about how to write a plugin but I found out that the server administrator has written a Plugin Development Kit in C++ for those who wish to write plugins for the interface.I don't know C++ so I cannot convert this kit into python scripts.Can anyone do this for me? or can anyone examine those scripts and tell me a way how to write those with python?The development kit is avaliable at the site ftp://ftp.chessclub.com/pub/icc/interface/blitzin2/plugins/
under the name PluginDevkit.zip
Any kind of help is appreciated.
Regards,
Ali Polatel 
		Do you Yahoo!? 
Yahoo! Search presents - Jib Jab's 'Second Term'-- 
http://mail.python.org/mailman/listinfo/python-list

ADO, Python and MS Exchange

2004-12-23 Thread warren ali
Hi all!

I'm new to python and I seem to have a hit a of a brick wall. I hope
you guys can help.

I'm trying to rewrite some of my vbscripts in python. This particular
script connects to a mailbox in MS Exchange via ADO and calculates the
mailbox size. I seem to have run into a couple of issues getting python
to talk to MS Exchange via ADO though. This is the code i'm using:

from win32com.client import Dispatch

conn = Dispatch('ADODB.Connection')
conn.ConnectionString = "URL=http://ctmx01/exchange/warren.ali";
conn.Open()

rs = Dispatch('ADODB.RecordSet')
rs.ActiveConnection = conn

rs.Open("Select http://schemas.microsoft.com/exchange/foldersize from
scope ('deep traversal of http://ctex01/exchange/warren.ali')",
conn.ConnectionString)

But running the code, all i get is this error message:

Traceback (most recent call last):
File "C:\Python24\ad.py", line 12, in -toplevel-
rs.Open("Select http://schemas.microsoft.com/exchange/foldersize
from scope ('deep traversal of http://ctex01/exchange/warren.ali')",
conn.ConnectionString)
File
"C:\Python24\lib\site-packages\win32com\gen_py\2A75196C-D9EB-4129-B803-931327F72D5Cx0x2x8\_Recordset.py",
line 93, in Open
return self._oleobj_.InvokeTypes(1022, LCID, 1, (24, 0), ((12, 17),
(12, 17), (3, 49), (3, 49), (3, 49)),Source, ActiveConnection,
CursorType, LockType, Options)
com_error: (-2147352567, 'Exception occurred.', (0, None, '', None, 0,
-2147217900), None)

Does anyone have any suggestions? I've kinda put the code together
based on this tutorial: http://www.mayukhbose.com/python/ado/index.php
but cant seem to adapt it to talk to exchange

This is the code that works via vbscript

http://support.microsoft.com/kb/2913

Set Rec = CreateObject("ADODB.Record")
Set Rs = CreateObject("ADODB.Recordset")

strURL = "http://exchangeserver/exchange/warren.ali";
Rec.Open strURL

sSQL = "Select"
sSQL = sSQL & "
""http://schemas.microsoft.com/exchange/foldersize""; "
'sSQL = sSQL & ", ""DAV:displayname"" "
sSQL = sSQL & " from scope ('deep traversal of " & Chr(34)
sSQL = sSQL & strURL & Chr(34) & "')"
'sSQL = sSQL & "Where ""DAV:isfolder""=true"

' Open the recordset.
Rs.Open sSQL, Rec.ActiveConnection

Thanks!!

--
Keeping it (sur)real since 1981. (now in
print:http://thinkingmachine.blogsome.com)

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


Actor pattern in GUI

2005-03-29 Thread M Ali
Hi,

I am trying to grok using actor patterns in a gui as explained here by
Andrew Eland:
http://www.andreweland.org/code/gui-actor.html 

The short article explains it using java with which i am not used to
at all. But he does provide a python example using pygtk:
http://www.andreweland.org/code/gui-actor.py

Could anyone look into it and maybe explain it a bit as i don't really
get at all what's happening?

In addition I am getting these error when I try to run it:

GLib-WARNING **: giowin32.c:1654: 3 is neither a file descriptor or a
socket
GLib-CRITICAL **: g_io_add_watch_full: assertion `channel != NULL'
failed
GLib-CRITICAL **: g_io_channel_unref: assertion `channel != NULL'
failed

Any ideas?

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


Re: Actor pattern in GUI

2005-03-30 Thread M Ali
Hmm... no takers? Too bad, the pattern and it's implementation in
python is pretty interesting...

[EMAIL PROTECTED] (M Ali) wrote in message news:<[EMAIL PROTECTED]>...
> Hi,
> 
> I am trying to grok using actor patterns in a gui as explained here by
> Andrew Eland:
> http://www.andreweland.org/code/gui-actor.html 
> 
> The short article explains it using java with which i am not used to
> at all. But he does provide a python example using pygtk:
> http://www.andreweland.org/code/gui-actor.py
> 
> Could anyone look into it and maybe explain it a bit as i don't really
> get at all what's happening?
> 
> In addition I am getting these error when I try to run it:
> 
> GLib-WARNING **: giowin32.c:1654: 3 is neither a file descriptor or a
> socket
> GLib-CRITICAL **: g_io_add_watch_full: assertion `channel != NULL'
> failed
> GLib-CRITICAL **: g_io_channel_unref: assertion `channel != NULL'
> failed
> 
> Any ideas?
> 
> Thanks...
-- 
http://mail.python.org/mailman/listinfo/python-list


Problem in pip

2015-12-04 Thread Ali Zarkesh
My pip can't download or upgrade anything
I use python 3.5 (win 32) and my pip version is 7.1.2.
The error message is this:

Exception:
Traceback (most recent call last):
File "c:\program files\python 3.5\lib\site-packages\pip\basecommand.py",
line 211, in main
status = self.run(options, args)
File "c:\program files\python
3.5\lib\site-packages\pip\commands\install.py", line 311, in run
root=options.root_path,
File "c:\program files\python 3.5\lib\site-packages\pip\req\req_set.py",
line 646, in install
**kwargs
File "c:\program files\python
3.5\lib\site-packages\pip\req\req_install.py", line 803, in install
self.move_wheel_files(self.source_dir, root=root)
File "c:\program files\python
3.5\lib\site-packages\pip\req\req_install.py", line 998, in move_wheel_files
insolated=self.isolated,
File "c:\program files\python 3.5\lib\site-packages\pip\wheel.py", line
339, in move_wheel_files
clobber(source, lib_dir, True)
File "c:\program files\python 3.5\lib\site-packages\pip\wheel.py", line
317, in clobber
shutil.copyfile(srcfile, destfile)
File "c:\program files\python 3.5\lib\shutil.py", line 115, in copyfile
with open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: 'c:\program files\python
3.5\Lib\site-packages\PyWin32.chm'

What do I do?
-- 
https://mail.python.org/mailman/listinfo/python-list


problem fixed

2015-12-04 Thread Ali Zarkesh
My problem fixed
That was only about User Account Control
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Twisted and txJSON-RPC

2014-11-14 Thread ali . hallaji1
Hi,
I want to write authentication with txjson-rpc.
please guide me in this method!
best Regards,
Ali Hallaji
-- 
https://mail.python.org/mailman/listinfo/python-list


Authentication method with txjson-rpc.

2014-11-14 Thread ali . hallaji1
Hi,
I want to write authentication by txjson,
Please help me in this way.
-- 
https://mail.python.org/mailman/listinfo/python-list


Attribute error while executing python script

2014-04-16 Thread ali hanif
gr_complex*1,"/home/ubuntu/radar-rx3.capture", True)
self.gr_file_source_0 =
gr.file_source(gr.sizeof_gr_complex*1,"/home/ubuntu/radar-rx3.capture",
True)
self.gr_delay_0_0 = gr.delay(gr.sizeof_gr_complex*1, delay_length)
self.blocks_mult
iply_xx_0 = blocks.multiply_vcc(1)
##
# Connections
##
self.connect((self.uhd_usrp_source_0, 0),
(self.wxgui_waterfallsink2_0, 0))
self.connect((self.gr_file_source_0_0, 0), (self.gr_delay_0_0, 0))
self.connect((self.gr_file_source_0, 0), (self.blocks_multiply_xx_0, 0))
self.connect((self.gr_delay_0_0, 0), (self.blocks_multiply_xx_0, 1))
self.connect((self.blocks_multiply_xx_0, 0), (self.uhd_usrp_sink_0, 0))
self.connect((self.blocks_multiply_xx_0, 0),
(self.wxgui_waterfallsink2_0_0, 0))
def get_variable_slider_1(self):
return self.variable_slider_1
def set_variable_slider_1(self, variable_slider_1):
self.variable_slider_1 = variable_slider_1
self.set_gain(self.variable_slider_1)
self._variable_slider_1_slider.set_value(self.variable_slider_1)
self._variable_slider_1_text_box.set_value(self.variable_slider_1)

def get_variable_slider_0(self):
return self.variable_slider_0
def set_variable_slider_0(self, variable_slider_0):
self.variable_slider_0 = variable_slider_0
self.set_delay_length(self.variable_slider_0)
self._variable_slider_0_slider.set_value(self.variable_slider_0)
self._variable_slider_0_text_box.set_value(self.variable_slider_0)
def get_samp_rate(self):
return self.samp_rate
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.wxgui_waterfallsink2_0.set_sample_rate(self.samp_rate)
self.wxgui_waterfallsink2_0_0.set_sample_rate(self.samp_rate)
self.uhd_usrp_sink_0.set_samp_rate(self.samp_rate)
self.uhd_usrp_source_0.set_samp_rate(self.samp_rate)
def get_gain(self):
return self.gain
def set_gain(self, gain):
self.gain = gain
self.uhd_usrp_sink_0.set_gain(self.gain, 0)
def get_delay_length(self):
return self.delay_length
def set_delay_length(self, delay_length):
self.delay_length = delay_length
self.gr_delay_0_0.set_delay(self.delay_length)if __name__ == '__main__':
parser = OptionParser(option_class=eng_option,usage="%prog: [options]")
(options, args) = parser.parse_args()
tb = top_block()
tb.Run(True)

ALI
-- 
https://mail.python.org/mailman/listinfo/python-list


Qestion

2015-08-22 Thread ali ranjbar
hi dear friend

I have python version 2.4.3

Which version of PIL is appropriate for me and how can I add it to my systems?

Regards
-- 
https://mail.python.org/mailman/listinfo/python-list


Need help with really elementary pexpect fragment

2011-12-19 Thread Saqib Ali

I want to write a pexpect script that simply cd's into a directory ("~/
install") and then runs a command from there. It should be so easy.
But even my cd command is failing. Can't figure out what the problem
is. The command line prompt is "[my machine name here] % "

Here is the code fragment:

print "Spawning Expect"
p = pexpect.spawn ('/bin/tcsh',)

print "Sending cd command"
i = p.expect([pexpect.TIMEOUT, "%",])
assert i != 0, "Time-Out exiting"
p.sendline("cd ~/install")

Here is the output:

Spawning Expect
Sending cd command
Time-Out exiting


How could I be screwing something so simple up??
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need help with really elementary pexpect fragment

2011-12-20 Thread Saqib Ali
Oops! Good call.
Thank you. You pointed out my mistake.


- Saqib




On Tue, Dec 20, 2011 at 12:31 AM, Nick Dokos  wrote:

> Saqib Ali  wrote:
>
> >
> > I want to write a pexpect script that simply cd's into a directory ("~/
> > install") and then runs a command from there. It should be so easy.
> > But even my cd command is failing. Can't figure out what the problem
> > is. The command line prompt is "[my machine name here] % "
> >
> > Here is the code fragment:
> >
> > print "Spawning Expect"
> > p = pexpect.spawn ('/bin/tcsh',)
> >
>
> If you execute /bin/tcsh by hand, do you get a "%" prompt?
>
> Nick
>
> > print "Sending cd command"
> > i = p.expect([pexpect.TIMEOUT, "%",])
> > assert i != 0, "Time-Out exiting"
> > p.sendline("cd ~/install")
> >
> > Here is the output:
> >
> > Spawning Expect
> > Sending cd command
> > Time-Out exiting
> >
> >
> > How could I be screwing something so simple up??
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Can I get use pexpect to control this process?

2011-12-21 Thread Saqib Ali

I have a program X that constantly spews output, hundreds of lines per
minute.
X is not an interactive program. IE: it doesn't take any user input.
It just produces a lot of textual output to STDOUT.

I would like to save the output produced by X into a different file
every 5 seconds regardless of the actual content. I want one file to
contain the output from seconds 0-5, another file should contain 6-10,
etc. etc.

Can I do this with pexpect? I'm not sure I can because the "before"
argument gives me EVERYTHING upto the most recent match. What I really
need is something that will give me what was produced between the last
2 calls to pexpect.expect().
-- 
http://mail.python.org/mailman/listinfo/python-list


Can't I define a decorator in a separate file and import it?

2011-12-22 Thread Saqib Ali


I'm using this decorator to implement singleton class in python:

http://stackoverflow.com/posts/7346105/revisions

The strategy described above works if and only if the Singleton is
declared and defined in the same file. If it is defined in a different
file and I import that file, it doesn't work.

Why can't I import this Singleton decorator from a different file?
What's the best work around?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can't I define a decorator in a separate file and import it?

2011-12-22 Thread Saqib Ali
MYCLASS.PY:

#!/usr/bin/env python
import os, sys, string, time, re, subprocess
import Singleton


@Singleton
class myClass:

def __init__(self):
print 'Constructing myClass'

def __del__(self):
print 'Destructing myClass'


SINGLETON.PY:


#!/usr/bin/env python
import os, sys, string, time, re, subprocess
import Singleton


@Singleton
class myClass:

def __init__(self):
print 'Constructing myClass'

def __del__(self):
print 'Destructing myClass'

TRACEBACK:

>>> import myClass
Traceback (most recent call last):
  File "", line 1, in 
  File "myClass.py", line 6, in 
@Singleton
TypeError: 'module' object is not callable



- Saqib





>>
> Post the code, and the traceback.
>
> ~Ethan~
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can't I define a decorator in a separate file and import it?

2011-12-22 Thread Saqib Ali
BTW Here is the traceback:

>>> import myClass
Traceback (most recent call last):
  File "", line 1, in 
  File "myClass.py", line 6, in 
@Singleton
TypeError: 'module' object is not callable



Here is Singleton.py:



class Singleton:

def __init__(self, decorated):
self._decorated = decorated

def Instance(self):
try:
return self._instance
except AttributeError:
self._instance = self._decorated()
return self._instance

def __call__(self):
raise TypeError(
'Singletons must be accessed through the `Instance`
method.')



Here is myClass.py:

#!/usr/bin/env python
import os, sys, string, time, re, subprocess
import Singleton


@Singleton
class myClass:

def __init__(self):
print 'Constructing myClass'

def __del__(self):
print 'Destructing myClass'
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can't I define a decorator in a separate file and import it?

2011-12-22 Thread Saqib Ali
Thanks for pointing out the mistake!
Works.
- Saqib




On Thu, Dec 22, 2011 at 4:31 PM, Ethan Furman  wrote:

> Saqib Ali wrote:
>
>> MYCLASS.PY:
>>
>> #!/usr/bin/env python
>> import os, sys, string, time, re, subprocess
>> import Singleton
>>
>
> This should be 'from Singleton import Singleton'
>
>
>
>  @Singleton
>> class myClass:
>>def __init__(self):
>>print 'Constructing myClass'
>>
>
> At this point, the *instance* of myClass has already been constructed and
> it is now being initialized.  The __new__ method is where the instance is
> actually created.
>
>
>
>>def __del__(self):
>>print 'Destructing myClass'
>>
>>
>>  > class Singleton:
> >
> > def __init__(self, decorated):
> > self._decorated = decorated
> >
> > def Instance(self):
> > try:
> > return self._instance
> > except AttributeError:
> > self._instance = self._decorated()
> > return self._instance
> >
> > def __call__(self):
> > raise TypeError(
> > 'Singletons must be accessed through the `Instance`
> > method.')
>
>
> ~Ethan~
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Changing the system clock with pexpect confuses pexpect!

2011-12-26 Thread Saqib Ali

See my code below.

I'm controlling a shell logged in as root with pexpect.

The class below has a method (startProc) which spawns a shell and
keeps it alive until told to destroy it (stopProc).

The other 2 methods in this class allow me to change the system clock
and to get the IP Address of this machine.

They all work fine except when I advance the system clock, and
then try to get the IP Address.
In that case, I get an exception because pexpect incorrectly thinks
the output it is getting from ifconfig is invalid. But it is not.
Pexpect is just confused. This doesn't happen when I move the clock
backwards. It only happens when I move the clock forward.

I believe what is going on is that internally pexpect uses the system
clock to keep track of when it receives data from spawned processes.
When I mess with the clock, that messes up the internal workings of
pexpect.

Any suggestions what I should do? I have numerous concurrent pexpect
processes running when I modify the clock. Is there anyway to prevent
them all from getting totally screwed up??

-


#!/usr/bin/env python
import pexpect, os, time, datetime, re

def reportPrint(string):
print string

def reportAssert(condition, string)
if condition == False:
print string
raise Exception


class rootManager:

rootProc = None
rootPrompt = "] % "
myPrompt = "] % "

def __init__(self):
pass




def startProc(self):
if self.rootProc != None:
reportPrint("\t\t- Root Process is already created")
else:
self.rootProc = pexpect.spawn ('/bin/tcsh',)
i = self.rootProc.expect([pexpect.TIMEOUT,
self.myPrompt,])
reportAssert(i != 0, "Time-Out exiting")

reportPrint("\t\t- Sending su")
self.rootProc.sendline("su")
i = self.rootProc.expect([pexpect.TIMEOUT, "Password: ",])
reportAssert(i != 0, "Time-Out exiting")

reportPrint("\t\t- Sending Password")
self.rootProc.sendline(ROOT_PASSWORD)
i = self.rootProc.expect([pexpect.TIMEOUT,
self.rootPrompt,])
reportAssert(i != 0, "Time-Out exiting")

reportPrint("\t\t- Root Process created")


def getIPAddr(self):
reportAssert(self.rootProc != None, "No active Root Process!")

reportPrint("\t\t- Sending ifconfig -a")
self.rootProc.sendline("ifconfig -a")
i = self.rootProc.expect([pexpect.TIMEOUT, self.rootPrompt,])
reportAssert(i != 0, "Time-Out exiting")

outputTxt = self.rootProc.before
ipList = [i for i in re.compile("(?<=inet )\d{1,3}\.\d{1,3}\.
\d{1,3}\.\d{1,3}").findall(outputTxt) if i != "127.0.0.1"]
reportAssert(len(ipList) == 1, "Cannot determine IP Address
from 'ifconfig -a': \n%s" % outputTxt)
return ipList[0]


def changeClock(self, secondsDelta):
reportAssert(self.rootProc != None, "No active Root Process!")

newTime = datetime.datetime.now() +
datetime.timedelta(seconds=secondsDelta)
dateStr = "%02d%02d%02d%02d%s" % (newTime.month, newTime.day,
newTime.hour, newTime.minute, str(newTime.year)[-2:])
reportPrint("\t\t- Sending 'date %s' command" % dateStr)
self.rootProc.sendline("date %s" % dateStr)
#Remember, by changing the clock, you are confusing pexpect's
timeout measurement!
# so ignore timeouts in this case
i = self.rootProc.expect([pexpect.TIMEOUT,
self.rootPrompt,],)






def stopProc(self):
if self.rootProc == None:
reportPrint("\t\t- Root Process is already destroyed")
else:

reportPrint("\t\t- Sending exit command")
rootProc.sendline("exit")
i = rootProc.expect([pexpect.TIMEOUT, self.myPrompt])
reportAssert(i != 0, "Time-Out exiting")

reportPrint("\t\t- Sending exit command")
rootProc.sendline("exit")
i = rootProc.expect([pexpect.TIMEOUT, pexpect.EOF])
reportAssert(i != 0, "Time-Out exiting")
self.rootProc.close()
self.rootProc = None
reportPrint("\t\t- Root Process Destroyed")



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


Problem while doing a cat on a tabbed file with pexpect

2012-01-15 Thread Saqib Ali

I am using Solaris 10, python 2.6.2, pexpect 2.4

I create a file called me.txt which contains the letters "A", "B", "C"
on the same line separated by tabs.

My shell prompt is "% "

I then do the following in the python shell:


>>> import pexpect
>>> x = pexpect.spawn("/bin/tcsh")
>>> x.sendline("cat me.txt")
11
>>> x.expect([pexpect.TIMEOUT, "% "])
1
>>> x.before
'cat me.txt\r\r\nA   B   C\r\n'
>>> x.before.split("\t")
['cat me.txt\r\r\nA   B   C\r\n']



Now, clearly the file contains tabs. But when I cat it through expect,
and collect cat's output, those tabs have been converted to spaces.
But I need the tabs!

Can anyone explain this phenomenon or suggest how I can fix it?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem while doing a cat on a tabbed file with pexpect

2012-01-15 Thread Saqib Ali

Very good question. Let me explain why I'm not opening me.txt directly
in python with open.

The example I have posted is simplified for illustrative purpose. In
reality, I'm not doing pexpect.spawn("/bin/tcsh"). I'm doing
pexpect.spawn("ssh myuser@ipaddress"). Since I'm operating on a remote
system, I can't simply open the file in my own python context.


On Jan 15, 2:24 pm, Dennis Lee Bieber  wrote:
> On Sun, 15 Jan 2012 09:51:44 -0800 (PST), Saqib Ali
>
>  wrote:
> >Now, clearly the file contains tabs. But when I cat it through expect,
> >and collect cat's output, those tabs have been converted to spaces.
> >But I need the tabs!
>
> >Can anyone explain this phenomenon or suggest how I can fix it?
>
>         My question is:
>
>         WHY are you doing this?
>
>         Based upon the problem discription, as given, the solution would
> seem to be to just open the file IN Python -- whether you read the lines
> and use split() by hand, or pass the open file to the csv module for
> reading/parsing is up to you.
>
> -=-=-=-=-=-=-
> import csv
> import os
>
> TESTFILE = "Test.tsv"
>
> #create data file
> fout = open(TESTFILE, "w")
> for ln in [  "abc",
>             "defg",
>             "hijA"  ]:
>     fout.write("\t".join(list(ln)) + "\n")
> fout.close()
>
> #process tab-separated data
> fin = open(TESTFILE, "rb")
> rdr = csv.reader(fin, dialect="excel-tab")
> for rw in rdr:
>     print rw
>
> fin.close()
> del rdr
> os.remove(TESTFILE)
> -=-=-=-=-=-=-
> ['a', 'b', 'c']
> ['d', 'e', 'f', 'g']
> ['h', 'i', 'j', 'A']
> --
>         Wulfraed                 Dennis Lee Bieber         AF6VN
>         wlfr...@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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


Re: Problem while doing a cat on a tabbed file with pexpect

2012-01-15 Thread Saqib Ali

The file me.txt does indeed contain tabs. I created it with vi.

>>> text = open("me.txt", "r").read()
>>> print "\t" in text
True


% od -c me.txt
000   A  \t   B  \t   C  \n
006


% ls -al me.txt
-rw-r--r--   1 myUsermyGroup   6 Jan 15 12:42 me.txt



On Jan 15, 6:40 pm, Cameron Simpson  wrote:
> On 15Jan2012 23:04, Steven D'Aprano  
> wrote:
> | On Sun, 15 Jan 2012 09:51:44 -0800, Saqib Ali wrote:
> | > I am using Solaris 10, python 2.6.2, pexpect 2.4
> | >
> | > I create a file called me.txt which contains the letters "A", "B", "C"
> | > on the same line separated by tabs.
> | [...]
> | > Now, clearly the file contains tabs.
> |
> | That is not clear at all. How do you know it contains tabs? How was the
> | file created in the first place?
> |
> | Try this:
> |
> | text = open('me.txt', 'r').read()
> | print '\t' in text
> |
> | My guess is that it will print False and that the file does not contain
> | tabs. Check your editor used to create the file.
>
> I was going to post an alternative theory but on more thought I think
> Steven is right here.
>
> What does:
>
>   od -c me.txt
>
> show you? TABs or multiple spaces?
>
> What does:
>
>   ls -ld me.txt
>
> tell you about the file size? Is it 6 bytes long (three letters, two
> TABs, one newline)?
>
> Steven hasn't been explicit about it, but some editors will write spaces when
> you type a TAB. I have configured mine to do so - it makes indentation more
> reliable for others. If I really need a TAB character I have a special
> finger contortion to get one, but the actual need is rare.
>
> So first check that the file really does contain TABs.
>
> Cheers,
> --
> Cameron Simpson  DoD#743http://www.cskk.ezoshosting.com/cs/
>
> Yes Officer, yes Officer, I will Officer. Thank you.

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


urllib and urllib2, with proxies

2006-08-08 Thread Ali . Sabil
hello all,

I just maybe hit a bug in both urllib and urllib2, actually urllib
doesn't support proxy authentication, and if you setup the http_proxy
env var to http_proxy=http://user:[EMAIL PROTECTED]:port/ and
https_proxy=$http_proxy i get a traceback :

Traceback (most recent call last):
  File "test_urllib.py", line 2, in ?
urllib.urlopen("https://sf.net/";)
  File "/usr/lib/python2.4/urllib.py", line 82, in urlopen
return opener.open(url)
  File "/usr/lib/python2.4/urllib.py", line 190, in open
return getattr(self, name)(url)
  File "/usr/lib/python2.4/urllib.py", line 313, in open_http
h.endheaders()
  File "/usr/lib/python2.4/httplib.py", line 798, in endheaders
self._send_output()
  File "/usr/lib/python2.4/httplib.py", line 679, in _send_output
self.send(msg)
  File "/usr/lib/python2.4/httplib.py", line 646, in send
self.connect()
  File "/usr/lib/python2.4/httplib.py", line 614, in connect
socket.SOCK_STREAM):
IOError: [Errno socket error] (-2, 'Name or service not known')


now with urllib2, it goes beyond that and connect and authenticate to
the proxy, however, instead of using CONNECT with https, it simply does
a GET, which result in a error 501 with a squid proxy:

Traceback (most recent call last):
  File "test_urllib.py", line 2, in ?
urllib2.urlopen("https://sf.net/";)
  File "/usr/lib/python2.4/urllib2.py", line 130, in urlopen
return _opener.open(url, data)
  File "/usr/lib/python2.4/urllib2.py", line 358, in open
response = self._open(req, data)
  File "/usr/lib/python2.4/urllib2.py", line 376, in _open
'_open', req)
  File "/usr/lib/python2.4/urllib2.py", line 337, in _call_chain
result = func(*args)
  File "/usr/lib/python2.4/urllib2.py", line 573, in 
lambda r, proxy=url, type=type, meth=self.proxy_open: \
  File "/usr/lib/python2.4/urllib2.py", line 597, in proxy_open
return self.parent.open(req)
  File "/usr/lib/python2.4/urllib2.py", line 364, in open
response = meth(req, response)
  File "/usr/lib/python2.4/urllib2.py", line 471, in http_response
response = self.parent.error(
  File "/usr/lib/python2.4/urllib2.py", line 402, in error
return self._call_chain(*args)
  File "/usr/lib/python2.4/urllib2.py", line 337, in _call_chain
result = func(*args)
  File "/usr/lib/python2.4/urllib2.py", line 480, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 501: Not Implemented


this is with python-2.4.3

thank you for your help

--
Ali Sabil

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


implicit variable declaration and access

2005-06-13 Thread Ali Razavi
Is there any reflective facility in python
that I can use to define a variable with a
name stored in another variable ?
like I have :
x = "myVarName"

what can I do to declare a new variable with the name of the string
stored in x. And how can I access that implicitly later ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: implicit variable declaration and access

2005-06-13 Thread Ali Razavi
Ali Razavi wrote:
> Is there any reflective facility in python
> that I can use to define a variable with a
> name stored in another variable ?
> like I have :
> x = "myVarName"
> 
> what can I do to declare a new variable with the name of the string
> stored in x. And how can I access that implicitly later ?
Got it! use higher order functions like Lisp!

code = x + '= 0'
exec(code)

code = 'print ' + x
exec(code)



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


Re: implicit variable declaration and access

2005-06-13 Thread Ali Razavi
Tom Anderson wrote:
> On Mon, 13 Jun 2005, Ali Razavi wrote:
> 
>> Is there any reflective facility in python that I can use to define a 
>> variable with a name stored in another variable ?
>>
>> like I have :
>> x = "myVarName"
>>
>> what can I do to declare a new variable with the name of the string 
>> stored in x. And how can I access that implicitly later ?
> 
> 
> Are you absolutely sure you want to do this?
> 
> tom
> 
Have you ever heard of meta programming ?
I guess if you had, it wouldn't seem this odd to you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: implicit variable declaration and access

2005-06-14 Thread Ali Razavi
Steven D'Aprano wrote:
> On Mon, 13 Jun 2005 12:18:31 -0400, Ali Razavi wrote:
> 
> 
>>Is there any reflective facility in python
>>that I can use to define a variable with a
>>name stored in another variable ?
>>like I have :
>>x = "myVarName"
>>
>>what can I do to declare a new variable with the name of the string
>>stored in x. And how can I access that implicitly later ?
> 
> 
> Any time you find yourself wanting to indirectly define variables like
> this, the chances are you would get better results (faster, less security
> risks, easier to maintain, easier to re-factor and optimise, more
> readable) if you change the algorithm.
> 
> Instead of:
> 
> x = "myVarName"
> create_real_variable(x, some_value)
> print myVarName
> 
> why not do something like this:
> 
> data = {"myVarName": some_value}
> print data["myVarName"]
> 
> It is fast, clean, easy to read, easy to maintain, no security risks from
> using exec, and other Python programmers won't laugh at you behind your
> back 
> 
> 
I ain't writing a real program, just summarizing a few languages
(Python, Smalltalk, Ruby, ...) meta programming facilities and compare 
them with each other, it will only be an academic paper eventually. Thus 
I am only trying out stuff, without worrying about their real world 
consequences. And yes you are right, I am not a Python programmer, well 
to be honest, I am not a real "any language" programmer, as I have never 
written any big programs except my school works, and I don't even intend
to become one, Sorry it's just too boring and repetitive, there are much
more exciting stuff for me in computer engineering and science than 
programming, so I will leave the hard coding job to you guys and let you 
laugh behind the back of whoever you want!
Have a good one!

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


header intact

2007-06-22 Thread datulaida ali

hai..
-- 
http://mail.python.org/mailman/listinfo/python-list

  1   2   >