How to write UNIX daemons in Python?

Discussion in 'Python' started by gnewsg@gmail.com, Sep 13, 2006.

  1. Guest

    Hi all. I've just finished to write an FTP daemon in Python.
    To do things well I'd like to write an 'insteller' to permit the end
    user to 'deeply' install the package inside the system. In details I
    would like that installer is able to do the following operations:

    - copy ftpd.py in /usr/bin.
    - depending on the system, it should be able to determinate where
    service startup directory is located (for example /etc/init.d) and
    copy a script able to automatically run /usr/ftpd.py at startup.
    - optionally install a manual callable with "man ftpd".
    - many other operations about the installation of a package.

    What should I use to do something like that? Do I have to use
    distutils? Do I have to use third party packages? Do I have to write a
    "setup.py" and solve the problem manually?
    This last solution is problematic becouse, for (dumb) example, Debian
    wants executable/programs to be located in /usr/bin while Fedora uses
    another path (for example /usr/sbin).

    Another question: what about .deb, .rpm, [...] packages?
    Does it possible to use them with Python programs?
    Resolving third party dependancies by using them could be a nice thing.


    Best regards
     
    , Sep 13, 2006
    #1
    1. Advertising

  2. wrote:

    > Hi all. I've just finished to write an FTP daemon in Python.
    > To do things well I'd like to write an 'insteller' to permit the end
    > user to 'deeply' install the package inside the system. In details I
    > would like that installer is able to do the following operations:
    >
    > - copy ftpd.py in /usr/bin.
    > - depending on the system, it should be able to determinate where
    > service startup directory is located (for example /etc/init.d) and
    > copy a script able to automatically run /usr/ftpd.py at startup.
    > - optionally install a manual callable with "man ftpd".
    > - many other operations about the installation of a package.
    >
    > What should I use to do something like that? Do I have to use
    > distutils? Do I have to use third party packages? Do I have to write a
    > "setup.py" and solve the problem manually?
    > This last solution is problematic becouse, for (dumb) example, Debian
    > wants executable/programs to be located in /usr/bin while Fedora uses
    > another path (for example /usr/sbin).
    >
    > Another question: what about .deb, .rpm, [...] packages?
    > Does it possible to use them with Python programs?
    > Resolving third party dependancies by using them could be a nice thing.


    You can use setuptools to generate scripts in the various bin-directories.
    And of course you could try and make setup.py detect the system & adapt the
    necessary paths accordingly.

    But the best thing to do would certainly be a package - however, I'm not
    aware that there is any support for that. But a look here might be a start:

    http://wiki.debian.org/DebianPythonFAQ

    Diez
     
    Diez B. Roggisch, Sep 13, 2006
    #2
    1. Advertising

  3. schrieb:
    > What should I use to do something like that? Do I have to use
    > distutils? Do I have to use third party packages? Do I have to write a
    > "setup.py" and solve the problem manually?
    > This last solution is problematic becouse, for (dumb) example, Debian
    > wants executable/programs to be located in /usr/bin while Fedora uses
    > another path (for example /usr/sbin).
    >
    > Another question: what about .deb, .rpm, [...] packages?
    > Does it possible to use them with Python programs?
    > Resolving third party dependancies by using them could be a nice thing.


    I would create packages, and therefore restrict attention to the
    systems that are to be supported.

    For RPM, there is a distutils bdist_rpm command which can help in
    generating the RPM. OTOH, it might be actually easier to write a .spec
    file and build the RPM "manually".

    For .deb, there is also a bdist_deb distutils command (although not
    part of the standard Python distribution), again, it is likely easier
    to use the standard Debian packaging tool chain (i.e. with an
    explicit debian/ subdirectory, initially populated with dh_make).

    In either case, it is probably a good idea to look at source packages
    to get started quickly.

    FWIW, Debian does *not* put daemon programs in /usr/bin. Debian
    follows the FHS, which specifies that system binaries go into
    /usr/sbin. /usr/bin is limited to user programs.

    Regards,
    Martin
     
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=, Sep 13, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrey
    Replies:
    0
    Views:
    354
    Andrey
    Sep 12, 2007
  2. Steven W. Orr
    Replies:
    0
    Views:
    434
    Steven W. Orr
    Sep 14, 2007
  3. PurpleServerMonkey

    Python, Daemons and D-Bus

    PurpleServerMonkey, May 24, 2008, in forum: Python
    Replies:
    3
    Views:
    346
    Diez B. Roggisch
    May 25, 2008
  4. barcaroller

    Unix Daemons in C++

    barcaroller, Nov 27, 2008, in forum: C++
    Replies:
    1
    Views:
    1,043
    Boris
    Nov 27, 2008
  5. elsiddik

    Unix Daemons in Perl -- Tutorial

    elsiddik, Nov 7, 2007, in forum: Perl Misc
    Replies:
    0
    Views:
    162
    elsiddik
    Nov 7, 2007
Loading...

Share This Page