Re: How to exit a cgi file after a download

2013-09-05 Thread inq1ltd


There is no such thing as a cgi form or cgi window. Your cgi script runs 
when the user requests a Web page, generates a page, and then ends. At that 
point, python has stopped running. If your want the client's browser window to 
close, that's not a python problem. If you want to invalidate the download link 
after one successful download, you'll have to add a unique identifier to the 
url and keep track of which identifiers are still valid.




Thanks for responding,

Technically cgi is a script.  But a form is what a cgi script file can create.

The form I asked about is html, it was generated by a cgi script file. So I 
should have written; a cgi script file generated html form, or a cgi script 
file generated html window. Lazy writing.
My mistake.

However I asked a question which now is mute. Once the user downloads the data 
the user can copy it, so why limit the download?.  

I appreciate the response,

jd
inqvista.com






 








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


How to exit a cgi file after a download.

2013-09-04 Thread inq1ltd
Python help.

I use the following code in a cgi file
to give the client a download link to 
download a file.

---

print %s % ('a href = Setup.zip Down 
Load /a')



A click on Down Load opens a pop up browser 
window which allows the user to choose where 
to download the Setup.zip file, then after 
the download, the pop up window closes.

My problem is that I want the cgi form, which 
contains the link, to also close after the 
download.  The only way I can figure out to 
close the cgi window is to give the user a 
button to close it.  

Without closing it, the client can download 
again and forever if they choose to because 
the cgi window is open and the link is still 
active. 

I am trying to find a way to close the cgi 
file or call another file after the download 
without adding a close button and asking the 
client to close the window.

jd



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


Re: python interface to iMacros

2013-08-24 Thread inq1ltd

 On 08/23/2013 09:13 AM, inq1ltd wrote:
  Python help,
  
  I am running iMacros from
  linux/firefox and doing most of
  what I want.
  
  But, there are times when I want to
  do something of the net and then
  back to the iMacros script.
  
  Are there any projects out there
  that will connect python to imacros,
  something on the order of pexpect?
 
 I have no idea really, but you can
 drive Firefox using a thing called
 selenium. 
 http://docs.seleniumhq.org/
 
 There is a python library for
 interfacing with selenium, and from
 that you can drive firefox from
 python.

I've looked at the site.  Sounds like something I'll try.  Thanks for the reply.

jimonlinux








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


python interface to iMacros

2013-08-23 Thread inq1ltd
Python help,

I am running iMacros from linux/firefox 
and doing most of what I want.

But, there are times when I want to do 
something of the net and then back 
to the iMacros script.   

Are there any projects out there
that will connect python to imacros,
something on the order of pexpect?

There is a commercial version available
for $400.00 If I could justify the cost,
I would probably pay it.

jimonlinux
inqvista.com




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


pexpect, loading an entry field

2013-08-06 Thread inq1ltd
python help;

I am using pexpect to open my program.
Can someone tell me how to get data to appear in 
an entry field.

After pexpect opens the my program I have tried to use 
send, sendline, and write functions to try to put data into 
the program's entry field.

However, the data is going to the terminal window, 
the window that is used to initiate the call to pexpect 
but not to the entry field in the open program.

I would appreciate suggestions.
jol

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


Re: pexpect, loading an entry field

2013-08-06 Thread inq1ltd

 pexpect looks simple to use. Please check this example
 http://www.pythonforbeginners.com/systems-programming/how-to-use-the-
pexpect
 -module-in-python/
  python help;
  
  I am using pexpect to open my program.
  Can someone tell me how to get data to appear in
  an entry field.
  After pexpect opens the my program I have tried to use
  send, sendline, and write functions to try to put data into
  the program's entry field.
  However, the data is going to the terminal window, 
  the window that is used to initiate the call to pexpect
  but not to the entry field in the open program. 
  I would appreciate suggestions.
  
  jol
  

Thanks for the response.

I have been there but that site gives me 
the same information that I get from 
noah.org.  I have the pexpect docs and they presume 
that this problem doesn't exist.

None of the information in the NOAH site or the FAQ's 
address this question. 

I'm using suse linux running python 2.7 and pexpect.

The data, when using send() method is going to the terminal window, 
This is the same window that is used to initiate the call to pexpect.

Pexpect opens the program but the send method sends
 data to the terminal window, not the entry field located
in the child spawned by pexpect.

interact works, as does close(), TIMEOUT, EOF, before, after, 
expect_exact and methods.  But the entry field does not 
load.

So my question is;

Why??




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


Re: Can someone suggest better resources for learning sqlite3? I wanted to use the Python library but I don't know sql.

2013-08-04 Thread inq1ltd
On Saturday, August 03, 2013 10:57:32 AM Aseem Bansal wrote:
 I was writing a Python script for getting the user stats of a
 website(Specifically codereview.stackexchange). I wanted to store the 
stats
 in a database. I found Python3's sqlite3 library. I found that I needed sql
 commands for using it.
 
 I have tried sql.learncodethehardway but it isn't complete yet. I tired
 looking on stackoverflow's  sql tag also but nothing much there. Can
 someone suggest me better resources for learning sql/sqlite3?


Go to:
sqlite-us...@sqlite.org
and join.

Ask any question, you will get an answer.
 
Print out the manual.  For someone that is not 
familiar with Relational DB programming it
may look like a newspaper from 
another planet, but you should have it.

You mentioned creating a database for stats. Learn 
how to create a table, and populate it. that is basic.
Ask how to on the users help site, then compare the 
method sent to you to the manual.  You need to know 
how the answer relates to the manual.

The sqlite manual is in the standard format that is the 
accepted world wide.  Once you can understand 
the manual format you can work your way through a 
lot of what you want to do. 

jimonlinux
inqvista.com







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


capture html screen with pexpect

2013-07-08 Thread inq1ltd
python help,

I can log into a web site with pexpect but
what I want to do is pipe the opening window 
to a file. 

Logging into the site opens the site window
 but I can't get the window to a file. 

I can't use screen capture I need to get
pexpect to pipe it to a txt file.

Any help will be appreciated.
jimonliinux

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


Re: os.putenv() has no effect

2013-06-18 Thread inq1ltd
On Tuesday, June 18, 2013 06:49:31 PM Johannes Bauer wrote:
 Hi group,
 
 I've tracked down a bug in my application to a rather strange
 phaenomenon: os.putenv() doesn't seem to have any effect on my platform
 
 (x86-64 Gentoo Linux, Python 3.2.3):
  os.getenv(PATH)
 
 '/usr/joebin:/usr/local/bin:/usr/bin:/bin:/usr/games/bin:/usr/sbin:/sbin:~/b
 in'
  os.putenv(PATH, /)
  os.getenv(PATH)
 
 '/usr/joebin:/usr/local/bin:/usr/bin:/bin:/usr/games/bin:/usr/sbin:/sbin:~/b
 in'
  os.getenv(FOO)
  os.putenv(FOO, BAR)
  os.getenv(FOO)
 
 Does anybody know why this would happen or what I could be doing wrong?
 Help is greatly appreciated.
 
 Thanks in advance,
 Johannes
 
 
if you are trying to add a dir to a linux path you need 
to understand how to add or change environment variables. 
research this;
  $ export PATH= $PATH: ???/???/???

jd
inqvista.com


 



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


Re: Using Python to automatically boot my computer at a specific time and play a podcast

2013-06-17 Thread inq1ltd
On Sunday, June 16, 2013 12:06:08 PM C. N. Desrosiers wrote:
 Hi,
 
 I'm planning to buy a Macbook Air and I want to use it as a sort of alarm. 
 I'd like to write a program that boots my computer at a specific time,
 loads iTunes, and starts playing a podcast.  Is this sort of thing possible
 in Python?
 
 Thanks in advance.
 
 CND

Up  to Jan 1, 2012 we had 6 computers that 
were connected to timers.

The timers were set to come on at various times 
during the day.  When the timer came on, the computer,
on boot up, ran a .BAT file that called our screen saver 
which in turn launched another program.

I don't know about Mac but this was all written 
on DOS machines.  With a little research and I'm sure it 
could be done through the bios on a Mac.  

The screen saver gave us time to opt out of the call to 
another program. So, simply turning on a 
machine could launch an OS file that will call 
your python module.

Another approach is building a python screen saver that 
reboots your computer at a specific time.  On reboot,
your OS calls a python screen saver with options, 
as mentioned. 

jd
inqvista.com










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


Re: sendmail smtplib.SMTP('localhost') Where is the email?

2013-05-31 Thread inq1ltd

Your responses helped.

The mailg for linux gave me information I didn't expect.

regards,
jol







On Friday, May 31, 2013 08:55:12 AM Cameron Simpson wrote:
 On 30May2013 15:48, inq1ltd inq1...@inqvista.com wrote:
 | python help,
 
 Please do not make new discussions by replying to an old discussion.
 
 It is not enough to change the subject line; unless you also remove
 any References: and In-Reply-To: header lines your message is still
 considered part of the old discussion.
 
 | I've tried this code which I got from:
 | http://www.tutorialspoint.com/python/python_sending_email.htm
 | 
 | I build this file and run it
 
 [...]
 
 |smtpObj = smtplib.SMTP('localhost')
 |smtpObj.sendmail(sender, receivers, message)
 |print Successfully sent email
 
 [...]
 
 | After running the the file and I get
 | Successfully sent email
 | 
 | My question is why doesn't webmaster get an email?
 
 Well, this suggests that the message has been accepted by the mail
 system on localhost. Not that final delivery was made anywhere else.
 
 You now have to read the log files on your mail system to see what happened.
 
 One easy check to do first is to see if it is still in your mail
 system but undelivered. On a UNIX system running the command:
 
   mailq
 
 should tell you that. If the queue is empty, the message has been
 sent somewhere and you must dig through the logs to find out where.
 If the message is in the queue then the mailq command will probably
 give a suggestion as to why.
 
 Cheers,-- 
http://mail.python.org/mailman/listinfo/python-list


sendmail smtplib.SMTP('localhost') Where is the email?

2013-05-30 Thread inq1ltd
python help,

I've tried this code which I got from:
http://www.tutorialspoint.com/python/python_sending_email.htm


I build this file and run it 
---//---

#!/usr/bin/python
 
import smtplib
sender = inq1...@inqvista.com
receivers = [webmas...@inqvista.com]

message = From: jol
To: webmaster 
Subject: SMTP e-mail test

This is a test e-mail message.


try:
   smtpObj = smtplib.SMTP('localhost')
   smtpObj.sendmail(sender, receivers, message)
   print Successfully sent email
except SMTPException:
   print Error: unable to send email 

--//--

After running the the file and I get 
Successfully sent email

My question is why doesn't webmaster get an email?

jol









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


Re: python 2.7 vs 2.5

2013-05-16 Thread inq1ltd
On Thursday, May 16, 2013 07:17:57 PM Jean-Michel Pichavant wrote:
 - Original Message -
 
 I am using python 2.7 to write
 
  the cgi file and my web server is using python 2.5.
 
 The answer lies in your question.
 
 JM
 

I appreciate the response,

However, My question was wrong.  

The traceback I got
couldn't be because of a difference in versions
because I programmed the cgi on the site. 

I found that the path to the cgi had to be complete,
something like this:

/home/users/web/xxx/yyy.inqvista/public_html/home/read/mail

anything else gets a traceback.

jd

 









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


python 2.7 vs 2.5

2013-05-15 Thread inq1ltd
My web server is using python 2.5.

My cgi file is trying to open a shelve.

I xxx out some of the path below. 

I am trying to find out if this 
error is caused because I am using python 2.7 to write 
the cgi file and my web server is using python 2.5.

I would appreciate a confirmation of this.

 line 85, in FentriesFilled dbase = shelve.open( vpath, 'c' ) File 
/usr/local/lib/python-2.5/lib/python2.5/shelve.py, line 225, in open return 
DbfilenameShelf(filename, flag, protocol, writeback) File 
/usr/local/lib/python-2.5/lib/python2.5/shelve.py,

 line 209, in __init__ Shelf.__init__(self, anydbm.open(filename, flag), 
protocol, writeback) File /usr/local/lib/python-2.5/lib/python2.5/anydbm.py, 
line 83, in open return mod.open(file, flag, mode) 

File /usr/local/lib/python-2.5/lib/python2.5/dbhash.py, line 16, in open 
return bsddb.hashopen(file, flag, mode) 

File /usr/local/lib/python-2.5/lib/python2.5/bsddb/__init__.py, line 306, in 
hashopen d.open(file, db.DB_HASH, flags, mode) bsddb.db.DBInvalidArgError: 
(22, 'Invalid argument --/home/users/web/x/yyy.inqvista/public_html/-
/email: unsupported hash version: 9') 

thanks,
jd



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


Re: Typing letters slowly using sys

2013-04-05 Thread inq1ltd
On Friday, April 05, 2013 08:10:53 AM Matt wrote:
 On Friday, April 5, 2013 10:04:49 AM UTC-4, Matt wrote:
  I am using sys to give the effect that I am typing letters slowly.
  Basically what I want to have happen is have it show Loading..
  with the word loading appearing instantly and then the periods
  appearing slowly, as most loading screens do.
  
  This is what I have.
  
  
  
  dots = ('')
  
  for x in dots:
   sys.stdout.write(x)
   
   sys.stdout.flush()
   
   time.sleep(0.2)
  
  I cannot for the life of me figure out how to get the dots to appear on
  the same line as Loading. Every way that I have attempted, the word
  Loading appears and then the dots appear on the next line.
 Sorry guys, I may have not been clear. The part I pasted does work, but I
 cannot figure out how to get that to print after the word Loading. So it
 will instantly print Loading, and then the ... will appear
 slowly

if you can write the dots on one one line, then try writing the word 
with an additional dot.
Loading .
Loading . .
Loading . . . 

in other words, over write the word Loading with one
additional dot each time a dot is called for.  

jd
inqvista.com







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


Re: tkinter / gui

2013-02-24 Thread inq1ltd
On Saturday, February 23, 2013 02:50:43 PM Rex Macey wrote:
 Here is one general and one specific question about creating GUIs using
 tkinter from a newbie.  I have created a class in which to hold some data. 
 I want to create a GUI to get the data from the user and store it in the
 object.  Browsing the web I see that a lot of examples on GUIs have the
 forms put into classes.  I'm not clear why.  Why is that? Second, I've
 created a form with a bunch of widgets on it, one of which is a listbox. 
 This is done with a script, not a class.   I've defined a method that
 responds to a Button Release event.  I know this works because I can print
 the value selected in the listbox while within the method.  However, I want
 the value of the listbox after I've closed the form.  How do I get that?
 Thanks.

There are a few ways to approach this.
without getting to far in depth here, 
you can do something like this.

This is not technically correct but a
simple concept of how to.

make a class
class Klbox
lbox = ''

def __init__(self):
self.FmkLbox()

def FmkLbox(self):
  mkLbox = Listbox(masterTK)  ## create the listbox in TK
  config.mkLbox( stuff, morestuff,  ## config it however you want
   selectmode = ???)  


  ## you may have to import your class Klbox, here 
  #depending where you are in your program
  then relate Klbox.lbox = (?? something selected from listbox) 

   # from somewhere else in your program you can
  import Klbox
  x = Klbox.lbox
  print x,

 Or, you can also learn how to use the
 Tkinter StringVar Class,   available in Tkinter manual
 but you will need to relate the StringVar to an attribute
 as I described above so you can get it from another 
 module or class in your program.

jd
inqvista.com
   

















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


Re: Simulate Keyboard keypress Delay

2013-02-14 Thread inq1ltd
On Wednesday, February 13, 2013 11:47:36 AM DaGeek247 wrote:
 I am using the windows api feature getasynckeystate() to check the status of
 every key pressed; like this;
 
 #always checking
 while(True):
 #iterate through list of ascii codes
 for num in range(0,127):
 #if ascii code key is being pressed
 if win32api.GetAsyncKeyState(num):
 #do stuff
 
 This works great, almost. The issue that comes up now is that every time i
 press a key, the code grabs two or three key presses.
 
 So i tried making sure that repeated keys weren't pressed repeatedly;
 
 #always checking
 while(True):
 #iterate through list of ascii codes
 for num in range(0,127):
 #if ascii code key is being pressed
 if win32api.GetAsyncKeyState(num):
 if oldkeychar == num:
 #don't do stuff
 else:
 #do stuff
 
 this works great, but It won't record stuff like 'look' or 'suffer' because
 it doesn't record repeated keys. So I try doing a delay instead;
 
 #always checking
 while(True):
 #iterate through list of ascii codes
 for num in range(0,127):
 #if ascii code key is being pressed
 if win32api.GetAsyncKeyState(num):
 if oldkeychar == num:
 if crrenttime  (time.time() - .5)
 #do stuff because key has been repeated, but not because
 it was held down else:
 #don't do stuff because key is pressed to soon
 else:
 #do stuff because key is not repeated
 currenttime = time.time()
 
 this almost works, but I end recording some double keypresses, and missing
 others. Does anybody have any suggestions?


this will only work on a windows machine. It is from C++ runtime lib 
msvcrt.dll


in py module 
import msvcrt

while 1:
ch = msvcrt.getch()   ## returns one char
if ch == 'Y' :
   # do stuff or break
break

print %d (%r)  % (ch, ch)


  # also,  kbhit()  #  returns true if char is available

  # also, ungetch(ch)  # undo char ch

jd
inqvista.com






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


Re: Any idea how i can format my output file with ********************Start file*********************** usinf Python 2.7

2013-02-10 Thread inq1ltd
On Saturday, February 09, 2013 03:27:16 PM Morten Engvoldsen wrote:
 Hi Team,
 I Have saved my output in .doc file and want to format the output with
 
 *Start the File 
 
 Some data here
 
 
 ***End of File*
 
 Can you let me know how can i do that using Python?


Look up the textwrap module 

import the textwrap module.

from the textwrap module you can
import dedent, wrap, and fill  

These are great for formatting text.

jd 
inqvista.com




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


Re: sqlite3 puzzle

2013-01-15 Thread inq1ltd
On Monday, January 14, 2013 11:09:28 PM llanitedave wrote:
 I'm trying to get an application working in Python 2.7 and wx.Python which
 contains an embedded sqlite3 file.  There are a few tables with foreign
 keys defined.  In looking at the sqlite3 documentation, it says
 
 Assuming the library is compiled with foreign key constraints enabled, it
 must still be enabled by the application at runtime, using the PRAGMA
 foreign_keys command. It goes on to say that foreign keys must be enabled
 separately for each connection, which is fine as my app has only one.
 
 So I put the following test code in my initialization method:
 
 # open database file
 self.geologger_db = sqlite3.connect('geologger.mgc')
 self.db_cursor = self.geologger_db.cursor()
 self.foreign_key_status = self.db_cursor.execute(PRAGMA foreign_keys =
 ON) self.foreign_key_status = self.foreign_key_status.fetchone()
 
 print self.foreign_key_status
 
 I ran this several times while I was arranging the downstream queries, and
 each time it returned '(1,)', which means foreign keys is enabled.
 
 But I was using a variable named 'cmd1' as a placeholder until I changed the
 name to the more descriptive 'self.foreign_key_status'.  Since I made the
 name change, however, the code only returns 'None'.  Reverting to the
 previous variable name has no effect.
 
 Yes, I'm closing the connection with self.db_cursor.close() at the end of
 each run.
 
 According to the sqlite3 website, getting no return value, not even a '0',
 means that the version of SQLite you are using does not support foreign
 keys (either because it is older than 3.6.19 or because it was compiled
 with SQLITE_OMIT_FOREIGN_KEY or SQLITE_OMIT_TRIGGER defined).
 
 How can that be a compilation issue when it worked previously?  Does this
 somehow relate to it being a Python plugin instance?
 
 I'm very confused.

I haven't run this myself but after 

self.foreign_key_status.fetchone()

try :
 self.geologger_db.commit()

then close the db

jimonlinux






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


Re: Python USB control on Windows 7?

2012-12-23 Thread inq1ltd
On Sunday, December 23, 2012 06:34:41 PM Chris Angelico wrote:
 On Sun, Dec 23, 2012 at 6:28 PM, Tim Roberts t...@probo.com wrote:
  Duncan Booth duncan.booth@invalid.invalid wrote:
 In this year's Christmas Raffle at work I won a 'party-in-a-box'
 including USB fairy lights.
 
 They sit boringly on all the time, so does anyone know if I can toggle
 the power easily from a script? My work PC is running Win7.
 
  Not easily, no.  It's not really a USB device -- I'm betting it doesn't
  even enumerate.  It's just sucking power from the USB wires.  There's
  nothing to control.
 
 Hmm. Can you control whether a particular port is on or off? (I have
 no idea what's possible with the underlying API, much less whether
 it's exposed.) It should in theory be possible - disable the
 appropriate USB port and the device loses power.
 
 ChrisA

If you have the time;

Using communication software, you can control a modem to call, hang up, and 
call again every few seconds. Since you can make a phone do the same thing, 
there is most likely a way to get those lights to respond the same way, at 
least by next Christmas.  

jd






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


Re: Python3 + sqlite3: Where's the bug?

2012-12-20 Thread inq1ltd
On Thursday, December 20, 2012 03:52:39 PM Johannes Bauer wrote:
 Hi group,
 
 I've run into a problem using Python3.2 and sqlite3 db access that I
 can't quite wrap my head around. I'm pretty sure there's a bug in my
 program, but I can't see where. Help is greatly appreciated. I've
 created a minimal example to demonstrate the phaenomenon (attached at
 bottom).
 
 First, the program creates a db and inits two tables foo and bar,
 which both only have a int value. Then foo is populated with unique
 ints.
 
 A fetchmanychks function is supposed to have the same behavior as
 fetchall(), but instead perform the operation in many subsequent
 fetchmany() chunks.
 
 When I traverse the foo table using cursor cur1 and insert into the bar
 table using cursor cur2, I receive at some point:
 
 Traceback (most recent call last):
   File y.py, line 25, in module
 cur2.execute(INSERT INTO bar (id) VALUES (?);, (v,))
 sqlite3.IntegrityError: PRIMARY KEY must be unique
 
 Which means that the fetchmany() read returns the *same* value again!
 How is this possible? If I either
 
 - Remove the db.commit()
 - Replace fetchmanychks(cur1) by cur1.fetchall()
 
 it works without error -- but I want neither (I want regular commits
 because sqlite3 becomes horribly slow when the journal becomes large and
 the tables nothing to do with each other anyways and atomicity is not
 needed in my case).
 
 Do I grossly misunderstand fetchmany() or where's my bug here?
 
 Thanks in advance,
 Joe
 
 
Joe,

Both of the following addresses will get you to the same place.

You will get an answer from the sqlite help site.

sqlite-us...@sqlite.org

General Discussion of SQLite Database sqlite-us...@sqlite.org


jd
inqvista.com


 
 
 #!/usr/bin/python3.2
 import sqlite3
 
 db = sqlite3.connect(foobar.sqlite)
 cur1 = db.cursor()
 cur2 = db.cursor()
 
 def fetchmanychks(cursor):
   cursor.execute(SELECT id FROM foo;)
   while True:
   result = cursor.fetchmany()
   if len(result) == 0:
   break
   for x in result:
   yield x
 
 cur1.execute(CREATE TABLE foo (id integer PRIMARY KEY);)
 cur1.execute(CREATE TABLE bar (id integer PRIMARY KEY);)
 for i in range(0, 20, 5):
   cur1.execute(INSERT INTO foo VALUES (?);, (i,))
 db.commit()
 
 ctr = 0
 for (v, ) in fetchmanychks(cur1):
   cur2.execute(INSERT INTO bar (id) VALUES (?);, (v,))
   ctr += 1
   if ctr == 100:
   db.commit()
   ctr = 0
 
  Wo hattest Du das Beben nochmal GENAU vorhergesagt?
  
  Zumindest nicht öffentlich!
 
 Ah, der neueste und bis heute genialste Streich unsere großen
 Kosmologen: Die Geheim-Vorhersage.
  - Karl Kaos über Rüdiger Thomas in dsa hidbv3$om2$1...@speranza.aioe.org-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mini browser with python

2012-12-07 Thread inq1ltd
On Thursday, December 06, 2012 03:15:42 PM Terry Reedy 
wrote:
 On 12/6/2012 1:15 PM, inq1ltd wrote:
  On Thursday, December 06, 2012 05:19:38 PM John 
Gordon wrote:
In mailman.567.1354808057.29569.python-
l...@python.org inq1ltd
  
  inq1...@inqvista.com writes:
 Right now I need some way to display
 15 to 20 lines of html in its own window or
 as part of my screen.

Could you open a shell window and run a text web 
browser such as
Lynx?
  
  That is a possibility but then every machine
  will have to have Lynx. That is not quite
  what the customer wants.
  
  Also, I can download the site to a file,
 
 Or you can download and work with it in memory.
 
   convert the data to text,
 
 Using existing html parser.
 
   then display it in a Text widget.
 
 The complication in displaying html is with placing images 
and other
 boxed content, including tables, and flowing text around the 
boxes. If
 the html you want to work with is simple and has a somewhat 
fixed
 format, you should be able to extract all the info as either text 
or a
 table and be able to format and place it how you want.


What you are suggesting is what was suggested when this 
project was originally discussed.

However, I was naive about the complications of simply 
viewing a web page. And, making something like this work on 
Linux and Windows.

I've come to the conclusion that processing the data with
a parser and formatting it in a widget is the only way to make it 
work on both platforms.  Parsing the data also gives one the 
ability to produce a module that will work in multiple versions of 
either platform and still keep control of all of the code. 

I appreciate the Help,
Regards,
jimonlinux

 

  







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


Re: mini browser with python

2012-12-06 Thread inq1ltd
On Thursday, December 06, 2012 01:52:15 AM Hans Mulder 
wrote:
 On 5/12/12 22:44:21, inq1ltd wrote:
  I can connect to and download a web page,
  html code, and save it to a file. If connected
  to the web, I can change the settings on KWrite
  to open the file and navigate the page,
  (just like a browser does).
  
  I want to view the html file without using a browser
  
  or KWrite as I do now.
  
  Customer wants a direct connect to a dedicated
  website. Their clients can be using any
  browser. This gives them a a direct connect to
  a dedicated website for a specific purpose.
  In other words I need a mini, simple browser;
  something I can build that will open, read and
  display a saved html or the connected url site.
 
 How about:
 
 import os.path, webbrowser
 
 webbrowser.open(file:// + os.path.abspath(your_file))
 
  I would appreciate some direction.
 
 You'd get more useful answers if you'd give some
 more context.  For example:
 
 * Which platform?
 * Which version of Python?
 * Which GUI (if any)?
 * What capabilities do you need?  CSS? Javascript?
 * Are there any unusual requirement?
 

A few responders have ask for this information. 

Platform can be linux or Windows.
Currently: Linux runs Python 2.7
 and Windows runs 2.6.3; 
Windows can be XP and above.
My program is built with Python and Tkinter
I convert the program using py2exe.

There are no special requirements. 
The client will design around my capabilities.

The html page will simply be a display of data. 

Right now I need some way to display 
15 to 20 lines of html in its own window or 
as part of my screen. 

I am trying to avoid using any commercial
browser. 

GTK has a webkit, and QT has a webkit and 
Suse, wich I use has libwebkitgtk-1_0-0.

All at some time I will have to look at all. 
I thought If someone had done this already 
The learning curve could be lowered.

Thanks for the interest,
jimonlinux

   


 
 Hope this helps,
 
 -- HansM-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mini browser with python

2012-12-06 Thread inq1ltd
On Thursday, December 06, 2012 05:19:38 PM John Gordon 
wrote:
 In mailman.567.1354808057.29569.python-l...@python.org 
inq1ltd inq1...@inqvista.com writes:
  Right now I need some way to display
  15 to 20 lines of html in its own window or
  as part of my screen.
 
 Could you open a shell window and run a text web browser 
such as Lynx?

That is a possibility but then every machine
will have to have Lynx.  That is not quite
what the customer wants.
  
Also, I can download the site to a file, convert 
the data to text,  then display it in a Text widget. 

I appreciate the help,
Regards,
jimonlinux
-- 
http://mail.python.org/mailman/listinfo/python-list


mini browser with python

2012-12-05 Thread inq1ltd
Python help.

I can connect to and download a web page,
html code, and save it to a file.  If connected 
to the web, I can use KWrite to open the file 
and navigate the page.

I want to view the html file without using a browser 
or KWrite as I do now. 

In other words I need a mini, simple browser; 
something I can build that will open, read and 
display a saved html file.

I would appreciate some direction.

jimonlinux

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


Re: mini browser with python

2012-12-05 Thread inq1ltd
On Wednesday, December 05, 2012 03:36:04 PM David 
Hutto wrote:
 I think this is the snippe that you want:
 
 david@david-desktop:~$ python
 Python 2.7.3 (default, Aug  1 2012, 05:16:07)
 [GCC 4.6.3] on linux2
 Type help, copyright, credits or license for more 
information.
 
  import urlliib
  url_to_read = 
urllib.urlopen('http://hitwebdevelopment.com')
 
  for line in url_to_read:
 ... print line

Print line will send the html code to my
sys.stdout
I need to view the code as if
I were opening it with a browser.

Now, I set KWrite to read the code just
as Firefox does. 
I want to incorporate a mini browser 
in a module to do the same.

regards,
jimonlinux








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


Re: mini browser with python

2012-12-05 Thread inq1ltd
On Wednesday, December 05, 2012 10:15:58 PM Hans 
Mulder wrote:
 On 5/12/12 20:36:04, inq1ltd wrote:
  Python help.
 
 ?This is not a Python question.
 
  I can connect to and download a web page,
  html code, and save it to a file. If connected
  to the web, I can use KWrite to open the file
  and navigate the page.
  
  I want to view the html file without using a browser
  or KWrite as I do now.
  
  In other words I need a mini, simple browser;
  something I can build that will open, read and
  display a saved html file.
 
 Why don't you use the browser you already know?
 
  I would appreciate some direction.
 
 You're more likely to get good recommendations on
 a forum dedicated to whichever OS you are using.
If this is not a Python question what is
the purpose of the htmllib module, or the sgmllib module,
or the formatter module, or the htmlentitydef module or
the HTMLParser module and others that are available 
for python??

regards,

jimonlinux











 
 
 
 Hope this help,
 
 -- HansM-- 
http://mail.python.org/mailman/listinfo/python-list


mini browser with python

2012-12-05 Thread inq1ltd
Python help.

I can connect to and download a web page,
html code, and save it to a file.  If connected 
to the web, I can change the settings on  KWrite 
to open the file and navigate the page, 
 (just like a browser does).

I want to view the html file without using a browser 
or KWrite as I do now. 

Customer wants a direct connect to a dedicated 
website.  Their clients can be using any 
browser. This gives them a a direct connect to 
a dedicated website for a specific purpose.
  
In other words I need a mini, simple browser; 
something I can build that will open, read and 
display a saved html or the connected url site.

I would appreciate some direction.



jimonlinux

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


Re: write to a file two dict()

2012-09-24 Thread inq1ltd
On Sunday, September 23, 2012 10:44:30 AM giuseppe.amatu...@gmail.com wrote:
 Hi
 Have two dict() of the same length and i want print them to a common file.
 
 
 a={1: 1, 2: 2, 3: 3}
 b={1: 11, 2: 22, 3: 33}
 
 in order to obtain
 
 1 1 1 11
 2 2 2 22
 3 3 3 33
 
 I tried
 
 output = open(dst_file, w)
 for (a), b , (c) , d in a.items() , b.items() :
 output.write(%i %i %i %i\n % (a,b,c,d))
 output.close()

Try this, not exactly what you want, but close.

Refine it to get what you want.

dictC = {}

a={1: 1, 2: 2, 3: 3}
b={1: 11, 2: 22, 3: 33}

for bkey in b.keys():

newlist = []
x = str(b.get(bkey, ''))
x = str(bkey)+x
newlist.append(x)

y = str(a.get(bkey, ''))
y = str(bkey)+y
newlist.append(y)

dictC[bkey] = newlist

print dictC, 


jimonlinux,
inqvista.com


 
 but i get the error ValueError: need more than 3 values to unpack.
 
 do you have some suggestions?.
 Thanks
 Giuseppe-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to configure Tkinter Listbox to disable state keeping selected item highlighted

2012-07-17 Thread inq1ltd
On Tuesday, July 17, 2012 06:55:21 AM Sarbjit singh wrote:
 I am having a problem configuring a listbox widget such that the selection
 remains highlighted even while it is set (programmatically) to the 
DISABLED
 state. Below code shows the problem:
 
 from Tkinter import *
 master = Tk()
 listbox = Listbox(master)
 listbox.pack()
 listbox.insert(END, Text1)
 listbox.insert(END, Text2)
 listbox.insert(END, Text3)
 listbox.selection_set(first=0, last=None)
 listbox.configure(exportselection=False)
 listbox.configure(state=DISABLED)
 
 Now when I change state to NORMAL, selected item is being highlighted. 
Is
 there a way I could disable widget (i.e. No response on mouse clicks) but
 keep the selected object remain highlighted?

Learn how to use radiobuttons.  I think this is what you want.

jd


 
 Intent: I want to utilise this widget on wizard App that I am creating. I
 would like this widget to indicate the current page / wizard number which
 the user selected. Is there any other widget I could use instead of it?
 (Labels possibly?)-- 
http://mail.python.org/mailman/listinfo/python-list


inno setup 5.5

2012-06-21 Thread inq1ltd
py help,

Can someone let me know where to get 
help with inno setup.

I get an error;
Can't find _thinter

Sounds like a path problem.

Everything works until it is packaged with
inno v5.5.

jd


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


Re: Strange threading behaviour

2012-06-21 Thread inq1ltd
On Thursday, June 21, 2012 04:19:41 PM Rotwang wrote:
 Hi all, I'm using Python 2.7.2 on Windows 7 and a module I've written is
 acting strangely. I can reproduce the behaviour in question with the
 following:
 
 --- begin bugtest.py ---
 
 import threading, Tkinter, os, pickle

try this;

from Tkinter import *

take it out of the other import line

jd 



 
 class savethread(threading.Thread):
  def __init__(self, value):
  threading.Thread.__init__(self)
  self.value = value
  def run(self):
  print 'Saving:',
  with open(os.path.join(os.getcwd(), 'bugfile'), 'wb') as f:
  pickle.dump(self.value, f)
  print 'saved'
 
 class myclass(object):
  def gui(self):
  root = Tkinter.Tk()
  root.grid()
  def save(event):
  savethread(self).start()
  root.bind('s', save)
  root.wait_window()
 
 m = myclass()
 m.gui()
 
 --- end bugtest.py ---
 
 
 Here's the problem: suppose I fire up Python and type
 
   import bugtest
 
 and then click on the Tk window that spawns and press 's'. Then
 'Saving:' gets printed, and an empty file named 'bugfile' appears in my
 current working directory. But nothing else happens until I close the Tk
 window; as soon as I do so the file is written to and 'saved' gets
 printed. If I subsequently type
 
   bugtest.m.gui()
 
 and then click on the resulting window and press 's', then 'Saving:
 saved' gets printed and the file is written to immediately, exactly as I
 would expect. Similarly if I remove the call to m.gui from the module
 and just call it myself after importing then it all works fine. But it
 seems as if calling the gui within the module itself somehow stops
 savethread(self).run from finishing its job while the gui is still alive.
 
 Can anyone help?-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Strange threading behaviour

2012-06-21 Thread inq1ltd
On Thursday, June 21, 2012 11:46:30 AM inq1ltd wrote:
 On Thursday, June 21, 2012 04:19:41 PM Rotwang wrote:
  Hi all, I'm using Python 2.7.2 on Windows 7 and a module I've written is
  acting strangely. I can reproduce the behaviour in question with the
  following:
  
  --- begin bugtest.py ---
  
  import threading, Tkinter, os, pickle


correct my last response to this,
 
try this;
 
from Tkinter import *
 
import threading, Tkinter, os, pickle

it works for me.




my module included

if __name__ == '__main__' :
print '##open bugtest , 29\n'
myclass()

so I could run 
python bugtest.py 
in a shell

 
 jd
 
  class savethread(threading.Thread):
   def __init__(self, value):
   threading.Thread.__init__(self)
   self.value = value
   
   def run(self):
   print 'Saving:',
   
   with open(os.path.join(os.getcwd(), 'bugfile'), 'wb') as f:
   pickle.dump(self.value, f)
   
   print 'saved'
  
  class myclass(object):
   def gui(self):
   root = Tkinter.Tk()
   root.grid()
   
   def save(event):
   savethread(self).start()
   
   root.bind('s', save)
   root.wait_window()
  
  m = myclass()
  m.gui()
  
  --- end bugtest.py ---
  
  
  Here's the problem: suppose I fire up Python and type
  
import bugtest
  
  and then click on the Tk window that spawns and press 's'. Then
  'Saving:' gets printed, and an empty file named 'bugfile' appears in my
  current working directory. But nothing else happens until I close the Tk
  window; as soon as I do so the file is written to and 'saved' gets
  printed. If I subsequently type
  
bugtest.m.gui()
  
  and then click on the resulting window and press 's', then 'Saving:
  saved' gets printed and the file is written to immediately, exactly as I
  would expect. Similarly if I remove the call to m.gui from the module
  and just call it myself after importing then it all works fine. But it
  seems as if calling the gui within the module itself somehow stops
  savethread(self).run from finishing its job while the gui is still
  alive.
  
  Can anyone help?-- 
http://mail.python.org/mailman/listinfo/python-list


Re: inno setup 5.5

2012-06-21 Thread inq1ltd
On Friday, June 22, 2012 08:30:16 AM Chris Angelico wrote:
 On Fri, Jun 22, 2012 at 1:34 AM, inq1ltd inq1...@inqvista.com wrote:
  Can't find _thinter
 
 Is this supposed to be _tkinter?
 
 Try copying and pasting the entire error message, including traceback.
 That often helps. At the moment, I can't know whether the error is in
 your transcription of the message or if in a source file somewhere (a
 misspelled import, for instance).
 
 Chris Angelico


Thanks for responding,

The following is as it is in the exe text doc.

Traceback (most recent call last):
  File INQVISTA.py, line 23, in module
  File INQVISTA.py, line 19, in __init__
  File INQVISTA_0.pyc, line 23, in __init__
  File INQVISTA_0.pyc, line 75, in __init__
  File INQVISTA_0.pyc, line 78, in FmakeBox
  File Tkinter.pyc, line 1643, in __init__
_tkinter.TclError: Can't find a usable init.tcl in the following directories: 
{C:/Program Files/lib/tcl8.5} {C:/Program Files/lib/tcl8.5} C:/lib/tcl8.5 
{C:/Program Files/library} C:/library C:/tcl8.5.2/library C:/tcl8.5.2/library


This probably means that Tcl wasn't installed properly.

 //

the line of code that the error msg refers to is:

Mwelc =  Tk () 
 
jd







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


Re: Numeric root-finding in Python

2012-02-12 Thread inq1ltd


I don't know the first thing about this math problem however,

if I were to code this I might try ;

   except ZeroDivisionError:
 assert w = -1

rather than;

   except ZeroDivisionError:
 assert w == -1


jimonlinux



On Sunday, February 12, 2012 06:41:20 AM Steven D'Aprano wrote:
 This is only peripherally a Python problem, but in case anyone has any
 good ideas I'm going to ask it.
 
 I have a routine to calculate an approximation of Lambert's W function,
 and then apply a root-finding technique to improve the approximation.
 This mostly works well, but sometimes the root-finder gets stuck in a
 cycle.
 
 Here's my function:
 
 import math
 def improve(x, w, exp=math.exp):
 Use Halley's method to improve an estimate of W(x) given
 an initial estimate w.
 
 try:
 for i in range(36):  # Max number of iterations.
 ew = exp(w)
 a = w*ew - x
 b = ew*(w + 1)
 err = -a/b  # Estimate of the error in the current w.
 if abs(err) = 1e-16:
 break
 print '%d: w= %r err= %r' % (i, w, err)
 # Make a better estimate.
 c = (w + 2)*a/(2*w + 2)
 delta = a/(b - c)
 w -= delta
 else:
 raise RuntimeError('calculation failed to converge', err)
 except ZeroDivisionError:
 assert w == -1
 return w
 
 
 Here's an example where improve() converges very quickly:
 
 py improve(-0.36, -1.222769842388856)
 0: w= -1.222769842388856 err= -2.9158979924038895e-07
 1: w= -1.2227701339785069 err= 8.4638038491998997e-16
 -1.222770133978506
 
 That's what I expect: convergence in only a few iterations.
 
 Here's an example where it gets stuck in a cycle, bouncing back and forth
 between two values:
 
 py improve(-0.36787344117144249, -1.0057222396915309)
 0: w= -1.0057222396915309 err= 2.6521238905750239e-14
 1: w= -1.0057222396915044 err= -2.6521238905872001e-14
 2: w= -1.0057222396915309 err= 2.6521238905750239e-14
 3: w= -1.0057222396915044 err= -2.6521238905872001e-14
 4: w= -1.0057222396915309 err= 2.6521238905750239e-14
 5: w= -1.0057222396915044 err= -2.6521238905872001e-14
 [...]
 32: w= -1.0057222396915309 err= 2.6521238905750239e-14
 33: w= -1.0057222396915044 err= -2.6521238905872001e-14
 34: w= -1.0057222396915309 err= 2.6521238905750239e-14
 35: w= -1.0057222396915044 err= -2.6521238905872001e-14
 Traceback (most recent call last):
   File stdin, line 1, in module
   File stdin, line 19, in improve
 RuntimeError: ('calculation failed to converge', -2.6521238905872001e-14)
 
 (The correct value for w is approximately -1.00572223991.)
 
 I know that Newton's method is subject to cycles, but I haven't found any
 discussion about Halley's method and cycles, nor do I know what the best
 approach for breaking them would be. None of the papers on calculating
 the Lambert W function that I have found mentions this.
 
 Does anyone have any advice for solving this?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Script randomly exits for seemingly no reason with strange traceback

2012-02-03 Thread inq1ltd

Check your code in that module for open parenthesis something like below..
Most likely your code is looking for the closing  parenthesis.
Start at the bottom and move up.

pink = str(self.RecordKey[2] --missing )  

jimonlinux



 On Fri, 03 Feb 2012 14:14:57 -0600, Andrew Berg wrote:
  It's a rare occurrence, but sometimes my script will terminate and I get
  this:
  
  Traceback (most recent call last):
File C:\path\to\script\script.py, line 992, in module
  
  That's it. And the line number is always the last line of the file
  (which in my case is a blank line).

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