User Profile

Collapse

Profile Sidebar

Collapse
Bierny
Bierny
Last Activity: Mar 20 '08, 08:08 AM
Joined: Feb 23 '07
Location: Poland
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Bierny
    replied to popen2 issue
    Hmm...
    What in case when the first script (the one that uses raw_input) is not a python script, but simply some other script that i can only execute?

    I am still trying :-)

    Thanks for your comments and i am waiting for new ones :-)

    Best regards,
    See more | Go to post

    Leave a comment:


  • Bierny
    started a topic popen2 issue

    popen2 issue

    Hi All,
    I am trying to do something new in python but at this moment i really don't know if it is possible.

    I have a very simple python script that will simply prompt for any text and when the text it entered by a user the script will display it on a screen.

    Code:
    myInput = raw_input("Write something:")
    print myInput
    What i am trying to do is to start this simple script...
    See more | Go to post

  • Bierny
    started a topic How to get a list of active processes under Unix

    How to get a list of active processes under Unix

    Hi All!
    I am writting a small script that will find a parent pid and from this point find a parent of a parent in order to kill this last parent :-)

    I know it sounds stange (at least ... ) but this is really what i have to do. So

    When the script starts it find it's parent pid, like this

    Code:
    ppid = os.getppid()
    Afterwards a list of active processes is fetched from a console command ps...
    See more | Go to post

  • Bierny
    replied to Zipping and unzipping
    Hi,
    Some time ago i wrote a script that downloads a zip archive and unpacks it. Here is a part of code that was taking care of extracting all files from the archive.

    Code:
    # open an archive file
    my_zipfile = zipfile.ZipFile(sampleZIPFilename,'r')
    
    # unzip all files from an archive
    for my_zippedfile in my_zipfile.namelist():
        f = open(my_zippedfile,'w')
        f.write(my_zipfile.read(my_zippedfile))
    ...
    See more | Go to post

    Leave a comment:


  • Bierny
    replied to Socket - send message
    Hi,
    Ok, I found it :-)

    Let's say i want to send a message with following bytes "00201":

    Code:
    import struct
    
    msg = struct.pack("!bbbbb", 0, 0, 2, 0, 1)
    mySocket.send(msg)
    
    ...
    and later in order to unpack a received message:

    Code:
    unpacked_msg = struct.unpack
    That should work ;-)

    Best...
    See more | Go to post

    Leave a comment:


  • Bierny
    started a topic Socket - send message

    Socket - send message

    Hi,
    I would like to write a script which will connect to a server. I know I have to set up a tcp connection and after that send a registration message which consists of tag, length and value fields. All fields are bytes.
    I have found a package "struct" which translates string to binary format but unfortunatelly I do not see appropriate format.

    How can i do that?

    Thanks in advance for any help/hints!...
    See more | Go to post

  • Bierny
    replied to Communication between threads
    Ok, so this is the usual handling of a thread. The server thread should be a main thread so it has control over the client thread.
    I can see a design mistake since I con not have to separete threads (meaning without main thread).
    In that case I will rebuid the script so there is one main thread which controls the other one.

    Thanks for your help!

    Best regards,
    See more | Go to post

    Leave a comment:


  • Bierny
    replied to Communication between threads
    Now I am lost ... but maybe we could try different approach. Please take a look at the following script:

    Code:
    #!/app/Python/2.4/bin/python
    
    import time
    from threading import Thread, Event
    
    ################################################################################
    # USER DEFINED CLASSES
    ################################################################################
    ...
    See more | Go to post

    Leave a comment:


  • Bierny
    replied to Communication between threads
    Hi,
    I have found some examples that, i believe, worked as you described. But there is one difference (at least from my point of view but since I am new in this kind of programming, I might be wrong :-) ) that it is controlled from the same class. So there is a class that has to create for instance 10 connections to the server. Each connection is a separate thread. Since they all share the same code every thread has access to the self._stopEvent ....
    See more | Go to post

    Leave a comment:


  • Bierny
    started a topic Communication between threads

    Communication between threads

    Hi,
    I am writing a Python script that will start two threads: one thread shall start the client application and catch logs from it and the other thread shall catch logs from the server side.
    So the first thread knows when it shall stop since it has a set of actions to be performed and when all it's tasks are done it simply terminates.
    Now i would like the other thread to terminate itself as soon as the first thread is gone....
    See more | Go to post

  • Bierny
    replied to spawn problem
    Hi,
    Thanks for quick reply! I just found the cause of the problem. It was, as cybervegan has written, the type of paramters passed to the constructor. Now it works as it should!

    Thanks again!

    Best regards,
    Bierny
    See more | Go to post

    Leave a comment:


  • Bierny
    started a topic spawn problem

    spawn problem

    Hi,
    I am quite new to Python but i found it really interesting and useful so I am trying to write even the smallest tools in this language. During this passion of creating everything in Python I get stuck on the following problem.

    I want to create a simple class that will be used as an interface to some application. The class shall start the application as a separate thread and try to connect to it. So, it looks like this...
    See more | Go to post
    Last edited by bartonc; Feb 24 '07, 03:45 AM. Reason: added [code][/code] tags
No activity results to display
Show More
Working...