jlm699 320 Veteran Poster

Is there any possibility that the page your browser is displaying is a cached version and hasn't updated to notify you of the user's deletion?

Try clearing ff's cache and then fetching the page again.

jlm699 320 Veteran Poster

You could do something along the lines of this:

# Open our input (hosts) file
file_in = open(filename)
# Open a temporary output file
file_out = open(fileoutname, 'w')
# host_found will tell us if we found the line define host {
host_found = False
# Now iterate over each line in the hosts file
for line in file_in:
    if host_found:
        # If we found the proper host, we won't write to output
        # but we'll want to monitor for the closing bracket to know
        # when to stop skipping lines
        if line.strip() == '}':
            host_found = False
    else:
        if line.strip() == 'define %s {' % host_ip:
            # we found the first line
            host_found = True
        else:
            # copy each line to output (except the ones we want to skip)
            file_out.write(line)

Then all you'll need to do is rename your temporary outfile to the same path and name as the hosts file.

jlm699 320 Veteran Poster

it just shows a load of {}.

firstRec = True
for fields in parser:
    if firstRec:
        fieldNames = fields
        firstRec = False
    else:
        dicts.append({})
        
for i,f in enumerate(fields):
    dicts[-1][fieldNames[i]] = f

In your code, you are iterating over the contents of parser. You ignore the first line, then set firstRec to False. The remainder of the lines are also ignored and you are appending an empty dictionary {} to your list called dicts.

Where's the code that's supposed to read the contents of the csv file? I don't see any attempt at doing so...

jlm699 320 Veteran Poster

What error does it give when the program "just stops"

jlm699 320 Veteran Poster

I believe sys.stdout.flush() is what you're looking for. Those stdio handles are just like open file handles

jlm699 320 Veteran Poster

Have you tried checking the return code of os.system?

jlm699 320 Veteran Poster

Use os.system("RD /s folderName") or subprocess.Popen depending on your python install

jlm699 320 Veteran Poster

'os.system(pathToBatFile)'

Is your pathToBatFile an absolute or relative path?

jlm699 320 Veteran Poster

udp or tcp?

UDP is an "unreliable" transfer protocol, ie if a packet is dropped or lost, it doesn't care. This is for high-demand but low-expectation connections (think streaming video: you don't care if you miss a frame or two because you can still see the entire video).

TCP is a reliable transfer protocol, with error correction. This method inherently is slower than udp as it needs to guarantee that every packet it sent successfully, thus it's important to use when you need high-fidelity transfers (ie, file transfers).

Read up on the different protocols here.

jlm699 320 Veteran Poster

Thank dears.So I have to chose one between wxpython and pygtk...your mean that pygtk is better to learn?
and another question.to use a database I learned sql language and there is not basic differences between mysql, sqlite and etc.

You don't need to choose one, you can learn them all and be your own judge for their pros/cons. None of them are "better" to learn, as all learning is beneficial and will bolster your skill set.

There are different implementations of SQL, and for each one there are different modules to take advantage of. This is another choice that depends on your necessity. I've used postgresql in the past with Python and had great success.

jlm699 320 Veteran Poster

The AttributeError is telling you that the instance of X lacks Y. If you study your error message:

background = pygame.image.load(bif).covert()
AttributeError: 'pygame.Surface' object has no attribute 'covert'

It first gives you the line of code for context, then the actual error (AttributeError). So it says the pygame.Surface object does not have an attribute called 'covert'. Looking back at the line of code you can deduce that pygame.image.load() returns a pygame object called a Surface. By tacking on covert() you're trying to access the attribute contained therein.

At this point, you could look into the pygame documentation and see that the Surface object does indeed NOT have a covert or covert_alpha method, but it does have convert and convert_alpha.

EDIT: Welcome to DaniWeb, I hope you enjoy your stay :)

jlm699 320 Veteran Poster

I guess if the conf file doesn't contain it, that would explain why it no longer works... Without that info or a backed-up version of the file, or any body in your area that's has any idea about sys admin stuff, you're pretty much left with starting over from scratch.

jlm699 320 Veteran Poster

the interactive shell (a la IDLE) is pretty darn awesome for testing stuff out.

Agreed. I use Notepad++ for my editing and have it set up with all kinds of whiz-bangs. I hit F6 to pull up an instance of PyCrust which is a Python Shell with autocomplete, syntax highlights, etc... I've also got shortcuts for running syntax checks, running the program I'm editing in Python, and a few others.

jlm699 320 Veteran Poster

sys.stdin is an "always open" file handle to the stdin and likewise sys.stdout. To use them, import sys.

jlm699 320 Veteran Poster

Because you're splitting on a semi-colon when none exist, which will produce a list of length 1. Then you're trying to access the 2nd element of that list (ie, 0 is the first, 1 is the second index), which results in an IndexError.

You should probably do some sanity checking before list slicing like if len(split_item) > 1: to avoid things like this...

EDIT: Please note, the failure occurs when you're splitting the results of grep and finding the genre, not when looking at the filename.

jlm699 320 Veteran Poster

What implementation of sql? There are different modules to use depending on whether it's postgresql, mysql, etc...

jlm699 320 Veteran Poster

Use tortoise's command line stuff

jlm699 320 Veteran Poster

would it be worth using a variable to catch whatever value is returned by the system.os

Nah, os.system just returns the return value.

You'd be better off using a subprocess and read the STDOUT pipe... Additionally, you could add a " > filename.txt" to the end of your command, which will dump the stdout into a file called filename.txt.

jlm699 320 Veteran Poster

I'd suggest secure copy via ssh (scp).

jlm699 320 Veteran Poster

Is there like a special program that I can download that will help me read the python files?

Python files are plain text. Use your favorite code editor to look at them.

jlm699 320 Veteran Poster

listen i want to make high professional program

You can add GUIs and pretty stuff later. When making a "high professional program" you must make sure it works well before it looks good.

Test the lines in the interpreter to figure out why it's taking so long.

The GUI frame does not respond because it's waiting for the function that you're calling to return. If you want the GUI updated while you're running a long/complex function you'll need to run it in a separate thread.

If you don't want to bother figuring out why your function is taking so long, you could use a Busy Cursor (hour glass) to indicate to the user that they should wait.

jlm699 320 Veteran Poster

You would use string formatting to insert the value of the variable in the string you're using to execute grep like so:

variable = 123
s = subprocess.Popen("grep -w %s Data.txt" % variable)

Here's the documentation on string formatting.

jlm699 320 Veteran Poster

computer is clushing.
and GUI programm's main frame become Not Responding.

Your computer is crashing?

Why don't you try to perform the urlretrieve section by itself in the interpreter. Maybe you've provided an invalid url or the wrong syntax.

jlm699 320 Veteran Poster

Also, when "Specify the number of threads" is asked, if I enter around 100,000, after a few seconds, it says thread could not be created? Any ideas why?

You're probably over-loading your cpu. There's no reason that you should ever be creating that many threads...

jlm699 320 Veteran Poster

In that case you can simply open a csv file and read it like a text file. Additionally there is a csvreader module in python, but I find it's simpler to just open the file as text and do your own splitting/processing.

And to get the user's input you'd use raw_input(prompt)

jlm699 320 Veteran Poster

#1 doubt:
Why do I have to specify 'self' while defining the function? I usually don't do it if the function isn't in a class, then why if it is in a class?

LOLWUT? myThread is a class, so naturally you should be specifying self... I don't really understand what you're asking though...

#2 doubt:
Why is variable 'a' first defined to be 1, and then globalized in the function specifically in the class? Why can't I do:

global a
a=1

class myThread(threading.Thread):    
    def run(self):
        print(a)
        a+=1

Because that's not how you use globals. You're supposed to identify a global variable as needed. So when your function gets "run", the command global a tells the program to pull in a reference of a from the global namespace.

And for your third doubt... I'm running the exact code with 100+ and not seeing repeats... so I'm not sure what you're talking about

jlm699 320 Veteran Poster

Explain what's wrong or else nobody can help you.

Here's the documentation on urlretrieve.

jlm699 320 Veteran Poster

pstats.py, pstats.pyo and pstats.pyc

pstats.py is the pstats module.
.pyc and .pyo are byte code versions of the module. When a module is run Python interprets the code into byte-code. To speed up this process, the byte code is stored in the .pyc file so that it doesn't compile every time.

You need to figure out where the pstats stuff is. And are you sure it's worked before? Or are they asking you to start from scratch?

Either way, here's the pstats documentation

jlm699 320 Veteran Poster

When i try to build a visual studio solution it does not want to build

Why not?

jlm699 320 Veteran Poster

Yup. smtplib is what you want. Just search this forum and you'll find boat loads of solutions.

jlm699 320 Veteran Poster

If you read your lines into a list via readlines() you can simply use indexing... something like this:

my_index = 0
while my_index < len(my_lines):
    current_line = my_lines[index]
    if 'CPU' in current_line:
        #get CPU data
        index += 1
        next_line = my_lines[index]
        # Get Ts data
        # Save data
    index += 1

That's an extremely simple solution that you could use. There's many ways to do it, but I hope this at least gets you on a path to answering your query

jlm699 320 Veteran Poster

py2exe.org is where you should be looking. I'm sure they'd love the help if you're willing to volunteer.

jlm699 320 Veteran Poster

This is coming along nicely. Next to do is: Set HP for player based on Level. Set Cargo for ships to a max level. Make a Black Market for selling of illegal items. Make Quest Side Missions. Finally, Set the players level to an EP system for points between levels. Easy enough, just more and more time..

Yup. Keep in mind that threads that reach this long in length are hard to follow. If you have further questions or need certain things explained in more detail please start a new thread, with the relevant code and your query right there in the first post. Oh and giving it a descriptive title will help too.

jlm699 320 Veteran Poster

...

What does your pstat code look like? Do you know if it's still in a valid directory that apache can get to ?

jlm699 320 Veteran Poster

Logs snippet below:
==========LOGS==============

a:CPU [ 85%]: asdf asd 123 xyz
A: Ts 23086, Netvalue 3286, someothervalues 3456
abc abc
xyz xyz
a:CPU [ 75%]: asdf asd 123 xyz
A: Ts 24088, Netvalue 3266, someothervalues 6576
======End of Logs ===========

Will your logs always have a: A: on the lines that your relevant information is on?

If so you could do something like this:

fh = open('my_log.inf')
flines = fh.readlines()
fh.close()

for line in flines:
    if line[:2\] == 'a:'
        #get CPU
    # etc...

Do you understand what I'm saying? But the important question is, is this the consisent pattern in your source data? Once you hammer that out this will be a simple task.

jlm699 320 Veteran Poster

What version of python are you using? Did it work before and stop or just never work at all? Are any other built-in functions working?

As a replacement you could use this:

def callable_(obj):
    if "__call()__" in dir(obj):
        return True
    else:
        return False

That should provide the same functionality

jlm699 320 Veteran Poster

In windows command line: start mailto:<email_addy>@<domain> will open the default mail client and create a new message to <email_addy>@<domain>. So simply pop that into os.system or subprocess or whatever your method of choice is, and that will take care of a windows platform machine.

I know there's something similar on linux machines but I'm drawing a blank at the moment...

The problem with this method comes into play when considering that most people prefer web-based email clients (at least according to a recent lifehacker poll). I know there are hacks to make an OS default to a web-based client instead of an installed piece of software, but I'm sure most of your users wouldn't be that savvy.

jlm699 320 Veteran Poster

I'm sure it has something to do with your PyScripter.

Try running the code from the console. It could just be that PyScripter dumps you into a shell after your program has completed... But I've never used that IDE, so I'm not sure.

jlm699 320 Veteran Poster

If you roll your own dialog box instead of using the standard offerings you can put anything you'd like on it...

jlm699 320 Veteran Poster

I don't think it is open source (Am I wrong?) So Should I contact their developing team?

Right... I suggested contacting them to see if they had any resources to point you in the right direction.

jlm699 320 Veteran Poster

In the top-most bar (with the <DANIWEB> logo) select Control Panel -> Edit Options. On that page look for Messaging & Notification section (should be second gray section)

Uncheck the boxes that read "Receive Occassional Email from DaniWeb" and "Receive Email from Other Members".

Finally, on the drop down for Default Thread Subscription Mode make sure "No email notification" is selected.

That should be all you need.

jlm699 320 Veteran Poster

evstevemd; are you aware of Digsby?

Digsby is a multi-protocol messaging/email consolidation client. As far as I'm aware, the program is designed in Python and wxPython; however I know they have certain elements (like the login window) that are designed in C++ and SWIG wrapped (this was a recent change as the original wx window was buggy).

That being said, don't give up hope! If you're looking to recreate what Digsby does as a learning excercise, keep in mind that it's possible and they are living proof

I'm sure you could even be as bold as to contact the developers and ask for learning resources! I wouldn't be surprised if they gave you some advice, as they seem to actively respond to users on their blog

jlm699 320 Veteran Poster

The equivalent device in python is slicing:

>>> my_text = 'Rajesh Kumar'
>>> my_text[3:]
'esh Kumar'
>>> my_text[1:2]
'a'
>>>

This example is analogous to the example on this page, which gives example usage of Java substring.

jlm699 320 Veteran Poster

If the python program quits with an error the return code is 1. If it successfully runs the return code is 0.

You can alternately specify your own return codes using sys.exit(return_code_value) at specific exit points of your code.

jlm699 320 Veteran Poster

I tried it anyways :) but it didn't work ... although i also did not get any error ... L( but if anyone knows a tkinter solution, would love to hear, intersly your suggestion is part of another problem i am trying to solve as i type .. how to lock focus on a window so the other windows canot be touched. Finding that solution might help me solve this one as well.

Perhaps then your solution is to switch GUI toolkits!

I've always preferred wx over tk and anxiously await a 3.0 compliant version of wx

jlm699 320 Veteran Poster

what is the best way to go? XML or Pickle? or Anything else?

Pickle. XML is way too much overhead for such a simple task.

jlm699 320 Veteran Poster

I'm not sure if tkinter has changed in py30 and above but shouldn't you be using awin.destroy ?

jlm699 320 Veteran Poster

If you were using an older version of python and working in the wx GUI toolkit I would suggest using a simple dialog box and giving it the directive ShowModal() , which makes it the only window with focus. No other parent window can be accessed until the dialog box has been taken care of. Then you could simply write in code to close the entire program if the dialog box is "cancelled" or closed.

Unfortunately I'm not that versed in tkinter, so I'm not sure if similar functionality exists or not.

jlm699 320 Veteran Poster

I know I am linking to the right stuff as the first block of code works.

That's very peculiar. I wonder if there is some sort of timing issue happening when you're repeatedly opening and closing the database connection...

Why don't you just try to move the db = , cursor = and db.close statements outside of the for loop and see if that gives you any better results.

As far as I can tell everything looks okay.

jlm699 320 Veteran Poster

open the Sound Recorder, but how do I make it to start recording?

That's not the kind of thing that subprocess was intended for. That kind of behavior is more akin to win32 hooks.

Subprocess can manipulate std input but not buttons on a GUI. As sneekula said, if the windows sound recorder can be fully utilized through command line processes then you'll be good to go, otherwise you'll need to figure out if that program has any win32 handles to work with.