1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] ConfigParser.MissingSectionHeaderError when parsing rsyncd config file with global...

Discussão em 'Python' iniciado por Stack, Setembro 16, 2025.

  1. Stack

    Stack Membro Participativo

    A configuration file generally needs section headers for each section. In rsyncd config files a global section need not explicitly have a section header. Example of an rsyncd.conf file:

    [rsyncd.conf]

    # GLOBAL OPTIONS

    path = /data/ftp
    pid file = /var/run/rsyncdpid.pid
    syslog facility = local3
    uid = rsync
    gid = rsync
    read only = true
    use chroot = true

    # MODULE OPTIONS
    [mod1]
    ...


    How to parse such config files using python ConfigParser? Doing the following gives an erorr:

    >>> import ConfigParser
    >>> cp = ConfigParser.ConfigParser()
    >>> cp.read("rsyncd.conf")

    # Error: ConfigParser.MissingSectionHeaderError: File contains no section headers.

    Continue reading...

Compartilhe esta Página