473,659 Members | 2,626 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to write UNIX daemons in Python?

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 '06 #1
2 2418
gn****@gmail.co m 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
Sep 13 '06 #2
gn****@gmail.co m 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
Sep 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1766
by: RosalieM | last post by:
I would like to understand what python needs to work on unix. And to understand how i can make it smalest possible? I dont understand at all setup. I searched in python.org and in sources but it is not clear at all for me. Can python run with a posix C compiler and minix or something like that ? Thanks
2
1509
by: Nigel King | last post by:
Hi, I have (my son has!) implemented protection against multiple instances causing havoc by creating a directory. This fails if it exists and thus in a single instruction one gets both the acquire and the test. Windows has it's mutex which solves the problem. Is there any better version for UNIX. Thanks
2
2995
by: timdoyle05 | last post by:
Hi, I have a question relating to how Unix commands can be issued from Python programs. Im am currently writing a large test script in python and I need this script to call three other separate Python scripts, where each one executes in it own thread of control. I would like to use a Unix command to get each script to run in its own shell. I have tried using the "Commands" module but after I issue the first "command", execution blocks...
18
1944
by: Xah Lee | last post by:
i've started to read python tutorial recently. http://python.org/doc/2.3.4/tut/tut.html Here are some quick critique: quick example: If the input string is too long, they don't truncate it, but return it unchanged; this will mess up your column lay-out but that's usually better than the alternative, which would be lying about a value. (If you really want truncation you can always add a slice operation, as in
4
2358
by: Michael | last post by:
Hi, I'm having difficulty finding any previous discussion on this -- I keep finding people either having problems calling os.exec(lepev), or with using python's exec statement. Neither of which I mean here. Just for a moment, let's just take one definition for one of the
3
1919
by: Matthew Warren | last post by:
I have the following piece of code, taken from a bigger module, that even as I was writing I _knew_ there were better ways of doing it, using a parser or somesuch at least, but learning how wasn't as fun as coding it... And yes alarm bells went off when I found myself typing eval(), and I'm sure this is an 'unusual' use of for: else: . And I know it's not very robust. As an ex cuse/planation, this is what happens when you get an idea in...
8
2885
by: dmoore | last post by:
Hi folks, I've seen the following issue come up in multiple posts to this mailing list: I have a python program that spawns a child process with popen or popen2 or popen3 or popen2.popen2 etc. the child process is interactive: it asks for input then spits out some output, asks for more input then spits out some output. for example, consider the trivial child program:
0
926
by: Andrey | last post by:
HI i have a newbie question about the file() function. I have 2 daemons running on my linux box. 1 will record the IDs to a file - logs.txt other 1 will open this file, read the IDs, and then "Clean up the file" -logs.txt Since these 2 daemons will run every 2-5mins, I think this will crash, isn't
3
1558
by: PurpleServerMonkey | last post by:
Seeking feedback from group members on a design I'm looking at using in a project. I've created an XML-RPC server and a number of Daemons, the idea is that the XML-RPC server gets a request from a user interface of some sort and then sends data to the Daemon processes to do work. Daemons will also need to feed back task information to the XML-RPC server. For the communications between the Daemons and XML-RPC server I was thinking of...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8339
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8751
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8535
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7360
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4176
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4338
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.