GithubHelp home page GithubHelp logo

pixelb / crudini Goto Github PK

View Code? Open in Web Editor NEW
424.0 12.0 63.0 327 KB

A utility for manipulating ini files

License: GNU General Public License v2.0

Makefile 0.45% Python 63.98% Shell 35.57%
ini ini-parser cli configuration-file config command

crudini's Introduction

crudini - A utility for manipulating ini files

Usage:

crudini --set [OPTION]...   config_file section   [param] [value]
crudini --get [OPTION]...   config_file [section] [param]
crudini --del [OPTION]...   config_file section   [param] [list value]
crudini --merge [OPTION]... config_file [section]

SECTION can be empty ("") or "DEFAULT" in which case,
params not in a section, i.e. global parameters are operated on.
If 'DEFAULT' is used with --set, an explicit [DEFAULT] section is added.

Multiple --set|--del|--get operations for a config_file can be specified.

Options:


  --existing[=WHAT]  For --set, --del and --merge, fail if item is missing,
                       where WHAT is 'file', 'section', or 'param',
                       or if WHAT not specified; all specified items.
  --format=FMT       For --get, select the output FMT.
                       Formats are 'sh','ini','lines'
  --ini-options=OPT  Set options for handling ini files.  Options are:
                       'nospace': use format name=value not name = value
                       'ignoreindent': ignore leading whitespace
  --inplace          Lock and write files in place.
                       This is not atomic but has less restrictions
                       than the default replacement method.
  --list             For --set and --del, update a list (set) of values
  --list-sep=STR     Delimit list values with "STR" instead of " ,".
                       An empty STR means any whitespace is a delimiter.
  --output=FILE      Write output to FILE instead. '-' means stdout
  --verbose          Indicate on stderr if changes were made
  --help             Write this help to stdout
  --version          Write version to stdout

Examples:


# Add/Update a var
  crudini --set config_file section parameter value

# Add/Update a var in the root or global area.
# I.e. that's not under a [section].
  crudini --set config_file "" parameter value

# Update an existing var
  crudini --set --existing config_file section parameter value

# Add/Update/Delete multiple variables atomically
  crudini --set config_file section parameter1 value \
          --set config_file section parameter2 value \
          --del config_file section parameter3

# Get multiple items from stdin
  env | crudini --get - '' USER --get - '' SHELL

# Add/Append a value to a comma separated list
# Note any whitespace around commas is ignored
  crudini --set --list config_file section parameter a_value

# Add/Append a value to a whitespace separated list
# Note multiline lists are supported (as newline is whitespace)
  crudini --set --list --list-sep= config_file section parameter a_value

# Delete a var
  crudini --del config_file section parameter

# Delete a section
  crudini --del config_file section

# output a value
  crudini --get config_file section parameter

# output a global value not in a section
  crudini --get config_file "" parameter

# output a section
  crudini --get config_file section

# output a section, parseable by shell
  eval "$(crudini --get --format=sh config_file section)"

# update an ini file from shell variable(s)
  echo name="$name" | crudini --merge config_file section

# merge an ini file from another ini
  crudini --merge config_file < another.ini

# compare two ini files using standard UNIX text processing
  diff <(crudini --get --format=lines file1.ini|sort) \
       <(crudini --get --format=lines file2.ini|sort)

# Rewrite ini file to use name=value format rather than name = value
  crudini --ini-options=nospace --set config_file ""

# Add/Update a var, ensuring complete file in name=value format
  crudini --ini-options=nospace --set config_file section parameter value

# Read indented ini file, like .gitconfig
  crudini --ini-options=ignoreindent --format=lines --get ~/.gitconfig

Installation

On windows ensure a python interpreter is installed. For example installing from https://www.python.org/downloads/ will put the py launcher and pip in the PATH.

Then ensure the iniparse module is installed by running the following from a "cmd" prompt:

pip install iniparse

Then crudini can be invoked by downloading just the crudini.py file and running like:

py crudini.py --help

On Linux systems crudini is generally available from your standard package manager, and installing will also ensure the iniparse dependency is appropriately installed on your system. You can also download and run the single crudini.py file directly to use latest version.

crudini's People

Contributors

ceremcem avatar gashev avatar joehakimrahme avatar kevok93 avatar kolanich avatar kvz avatar lfaraone avatar lhh avatar nkinder avatar pirateland avatar pixelb avatar suhussai avatar zbenjamin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crudini's Issues

section variables

Is there any way to prevent section keys to overwrite each other on multiple section reads with --format sh?

[section1]
source = value1
dest = value1

[section2]
source = value2
dest = value2
eval $(crudini --get --format sh ini section1)
eval $(crudini --get --format sh ini section2)

read complete ini file in shell format

Does crudini have support for reading the whole content (sections, keys) in one read with --format sh?

The documentation suggests I have to iterate over all sections in order to do that. That is inefficient and time consuming because the ini file is read (opened, closed) for each iteration...

FileLock does not work with system lock

You will use follow code

class FileLock(object):
    """Advisory file based locking.  This should be reasonably cross platform
       and also work over distributed file systems."""
    def __init__(self, exclusive=False):
        # In inplace mode, the process must be careful to not close this fp
        # until finished, nor open and close another fp associated with the
        # file.
        self.fp = None
        self.locked = False

        if os.name == 'nt':
            import msvcrt

            def lock(self):
                msvcrt.locking(self.fp.fileno(), msvcrt.LK_LOCK, 1)
                self.locked = True

            def unlock(self):
                if self.locked is True:
                    msvcrt.locking(self.fp.fileno(), msvcrt.LK_UNLCK, 1)
                self.locked = False

Also

                while True:
                    self.lock()
                    fpnew = os.fdopen(os.open(self.filename, open_mode, 0o666))
                    if os.path.sameopenfile(self.fp.fileno(), fpnew.fileno()):

It does not work on WIndows platform!!!

This code have two or three level simplify ready at now...

Crudini omits keys/params

Crudini omits certain keys in sections like remote (see below); tested on Linux and Cygwin. It looks like the underlying iniparse library is the culprit.

Can you confirm the issue and tell which kind of keys are dropped? If this is potentially occuring with a multitude of key names I would have to drop Crudini for my current project.

> cat transport.ini                                                                                                                            [Transport]
local  = /tmp
remote = /tmp/TEST.sh
upload = false
> crudini --get --format sh transport.ini Transport
local=/tmp
upload=false

Thread safe Crudini

Crudini is an excellent tool, because it is not thread safe it's not possible to use it multithread environments, like webapplication or when more than 1 sysadmin use it to alter the same file.

New crudini versions for Ubuntu

Good evening!

Ubuntu 18.04 offers old v0.7 crudini package to install.
Maybe you can advise what method to use to install latest crudini verstion in Ubuntu ? Some pip or something else?
I plan to use crudini mostly in bash environment.

PS: just found #23
maybe it still working:
apt-get install python-iniparse; curl https://raw.githubusercontent.com/pixelb/crudini/master/crudini > /usr/local/bin/crudini && chmod a+x /usr/local/bin/crudini

but it seems it at least doesn't copy man page

Thanks in advance!

Support for "[[section]]"

Configuration files use sometimes sections with double brackets (e.g. [[graphite]] in influxdb.conf or [[servers]] in ldap.toml for Grafana), but this syntax seems to be actually unsupported.
Would it be possible to support that?
Thanks!

Feature Request: Find section where parameter is defined

I have a use case where I would like to find the section in which a parameter is set to a specific value. Given the config_file:

[host1]
user=user1

[host2]
user=user2

I would like crudini --find config_file user user2 to output host2. This would help me use the information I have to find the section I want to modify or identify to the user as being active.

crudini --get suppresses parameters that overlap with those in [DEFAULTS]

nova.conf.zip

When I query the option directly, I can get the value.

$sudo crudini --get --format=lines /etc/nova/nova.conf neutron auth_strategy
[ neutron ] auth_strategy = keystone

But when I query the section with the option <auth_startegy>, I can't get it.

$ sudo crudini --get --format=lines /etc/nova/nova.conf neutron
[ neutron ] metadata_proxy_shared_secret = 123
[ neutron ] service_metadata_proxy = True
[ neutron ] admin_password = 123
[ neutron ] admin_username = neutron
[ neutron ] admin_tenant_name = service
[ neutron ] admin_auth_url = http://controller:35357/v2.0
[ neutron ] url = http://controller:9696

So, I think it may be missing when the files has same options in different section.

$ sudo crudini --get --format=lines /etc/nova/nova.conf DEFAULT auth_strategy
[DEFAULT ] auth_strategy = keystone

$ sudo crudini --get --format=lines /etc/nova/nova.conf DEFAULT
[ DEFAULT ] firewall_driver = nova.virt.firewall.NoopFirewallDriver
[ DEFAULT ] linuxnet_interface_driver = nova.network.linux_net.LinuxOVSInterfaceDriver
[ DEFAULT ] security_group_api = neutron
[ DEFAULT ] network_api_class = nova.network.neutronv2.api.API
[ DEFAULT ] verbose = True
[ DEFAULT ] vncserver_proxyclient_address = 192.168.122.11
[ DEFAULT ] vncserver_listen = 192.168.122.11
[ DEFAULT ] my_ip = 192.168.122.11
[ DEFAULT ] auth_strategy = keystone
[ DEFAULT ] rpc_backend = rabbit

Platform and Python support

Crudini does not work with Python 3 or under Windows - although you can install it via pip without a problem. Will Crudini be improved to support Windows and Python 3? If not I would at least suggest to mention the limitations in the Readme.

Turn crudini into a Python library

openstack-config seems to rely in crudini for manipulating configuration files. I'm working on a Python project for automation and troubleshooting in OpenStack and, as part of that project, I need to retrieve information from OpenStack configuration files. I think it makes sense to use crudini, as that's what it's used for installation and management and mentioned in OpenStack documents.

Problem is that crudini is a command-line tool and not a Python library. In order to retrieve data from OpenStack configuration files, I could spawn a subprocess calling /usr/bin/crudini but this is a very limited and weak interface mechanism (build a command-line, spawn crudini, parse standard output and exit code). I would prefer being able to "link" crudini as a library and, instead, using a Python native interface. For example, by calling a function or instantiating a class.

At the moment, the only functionality from crudini that I need is being able to retrieve key/value pairs (e.g. from section DEFAULT, retrieve the value for the report_interval key in file /etc/neutron/neutron.conf).

Installation

How Can I install it on Debian 7.0?
its not available via Repo, neither via apt-get
the setup.py gives some error,
make all commands prints out something weird.

Please Help me.

RFE: show whether config was updated or not

It would be nice if crudini can print whether it really altered the config. Eg:
changed: file foo has been successfully altered
or
ok: no change needed
when the var/config is already set or deleted.

This would allow better usage in ansible playbooks. Right now it is not possible if command actually changed something or not.

Crudini should check that stdin is valid before callin sys.stdin.isatty()

I have a service which uses crudini to read a config file. Since my program is running as a service under systemctl, the stdin is closed. This seems to cause this exception:

File "/usr/bin/crudini", line 969, in
sys.exit(main())
File "/usr/bin/crudini", line 966, in main
return crudini.run()
File "/usr/bin/crudini", line 831, in run
if sys.stdin.isatty():
AttributeError: 'NoneType' object has no attribute 'isatty'

I think that this could be avoided if crudini would check that sys.stdin is not None before calling isatty().

Whitespace around =

I want to be able to set a value like this:
VAR=value

rather than,
VAR = value

and if it is updating an existing value to preserve the absence of whitespace.

--set behaves more like --add

Running the --set command twice for the same parameter in the same section results in 2 entries. Thus it behaves more like an "add" operation. It does not replace the existing value by the new one.

I have tried this with a MySQL configuration file on Debian 9. Details and commands: see my question on AskUbuntu.

Workaround: use --del before using --set.

Support leading whitespace

Is there a reason not to support leading whitespace? E.g.

[SectionA]
    key1 = value1
    key2 = value2

crudini points parsing errors:

dmelo@merov2:~$ crudini --get a.ini SectionA key1
File contains parsing errors: <???>
    [line  2]:     key1 = value1

    [line  3]:     key2 = value2

symbolic link is changed to a regular file

(copy-edited from a private bz, replacing openstack-config with crudini in examples)

# ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
# ll /etc/neutron/plugin.ini
lrwxrwxrwx. 1 root root 37 Jun 13 14:38 /etc/neutron/plugin.ini -> /etc/neutron/plugins/ml2/ml2_conf.ini

Then, configure the plugin file with the crudini command.

# crudini --set /etc/neutron/plugin.ini ml2 tenant_network_types vlan
# ll /etc/neutron/plugin.ini
-rw-r-----. 1 root neutron 3959 Jun 13 14:39 /etc/neutron/plugin.ini

The symbolic link file is changed to a regular file and its content is
different from the original file.

# diff -i -U0 /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
--- /etc/neutron/plugins/ml2/ml2_conf.ini       2016-06-10 16:18:14.364982681 +0900
+++ /etc/neutron/plugin.ini     2016-06-13 14:39:40.022264671 +0900
@@ -14 +14 @@
-tenant_network_types = vxlan
+tenant_network_types = vlan

Wishlist: put options next to commented-out ones

I have a config file that looks like this:

[pov-server-page]

# If set to 0 (default), running pov-update-server-page won't do anything
# enabled = 1

# Apache password file; use htpasswd(1) to create and manage it
# auth_user_file = /etc/pov/fridge.passwd

When I change any of the options crudini puts the new setting at the top of the section:

$ git diff /etc/pov/server-page.conf
--- a/pov/server-page.conf
+++ b/pov/server-page.conf
@@ -1,4 +1,5 @@
 [pov-server-page]
+enabled = 1

 # If set to 0 (default), running pov-update-server-page won't do anything
 # enabled = 1

Is there any chance crudini could recognize the existing commented-out option and put the new value after it?

Complication: multiline options exist, e.g.

# Uncomment to compute disk usage of certain locations once a day
# disk_usage =
#     /var
#     /home
# Alternatively, detect all mounted partitions with
# disk_usage = all

and ideally the newly-added one would be after the entire comment block.

(If you're curious, the config file is for pov-server-page)

fips-140 compliance

using md5 for checksum violates FIP-140 compliancy suggest changing _chksum function to use sha256 (or something) rather than md5

def _chksum(self,data):
h = hashlib.sha256()
h.update(data)
return h.digest()

Support of repeated sections

I'm trying to use crudini on wireguard's config used by wg-quick.

There's a nice example of this file right on the main page: https://www.wireguard.com/

Let's repeat it here:

[Interface]
PrivateKey = yAnz5TF+lXXJte14tji3zlMNq+hd2rYUIgJBgB3fBmk=
ListenPort = 51820

[Peer]
PublicKey = xTIBA5rboUvnH4htodjb6e697QjLERt1NAB4mZqp8Dg=
AllowedIPs = 10.192.122.3/32, 10.192.124.1/24

[Peer]
PublicKey = TrMvSoP4jYQlY6RIzBgbssQqY3vxI2Pi+y71lOWWXX0=
AllowedIPs = 10.192.122.4/32, 192.168.0.0/16

Notice the multiple [Peer] sections.

When using crudini on this Peer section, I only get the last section. Did I miss something in the docs ?

add flag to allow creating a parameter if it does not exist

Not sure if I'm missing something but i would like to have crudini add the parameter if it's missing using a flag --allow-missing or something.

using openstack-config command which basically calls crudini by passing all given arguments.
Some boilerplate files sometimes miss a few default parameters which really should be there.

So my script will fail with:
Parameter not found: rabbit_hosts

Parameter not added in the correct location when "include" directives are involved

I'm trying to manipulate php-fpm config files.

On php-fpm.conf, you have a [global] section, and at the end an include=/etc/php/7.0/fpm/pool.d/*.conf.

These additionnal config files contains others section definition.

Problem is, when you want to add a non-already-existing parameter, its get added at the end of the section, namely after the include directive. In the end, this cause the parameter to be added in another section of the config file.

I think this could be easily resolved by adding new parameters right after the the section name, what do you think ?

How do I get the values, for multiline options ?

As in this example:

[service_providers]       
service_provider=LOADBALANCER:Haproxy:neutron.services.loadbalancer.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default
service_provider=VPN:openswan:neutron.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default

i.e, there can be multiple service_provider params under the section, I want to get them all, from my sh script, and be able to modify either of them.

I tried a crudini --get <file> service_providers service_provider and I got only the last param set!
Am I missing any option here, or this is not supported?

add support for ssh config files (~/.ssh/config)

It would be really nice if crudini would be able to configure ssh config files too.

If anyone is aware about another tool that can do this please post a message. Using sed is not really the best (and safe) way to do it.

crudini --get gets all strings in lower case

Hello!

original section in text file:

[server__gigataxi_prod]
_type=server
ServerDomainName=gigataxi.gigataxi.ru
ServerHostName=gigataxi.ru
ServerIP4=x.x.x.x
ServerSyncGbin=1
SrvCfgSync_Dirs2Git=/etc,/usr/local/etc,/gbin,/root,/home/vladp,/home/admin/conf
SrvCfgSync_Enable=1
SrvCfgSync_RsyncFilters=rsync_filters_gigataxi.ru
[email protected]
ServerSSHport=22

on some my servers it gets all lower case:

crudini --get /gbin/structure.ini server__gigataxi_prod
_type
serverdomainname
serverhostname
serverip4
serversyncgbin
srvcfgsync_dirs2git
srvcfgsync_enable
srvcfgsync_rsyncfilters
srvcfgsync_shhremote
serversshport

sometimes it shows correct (original) data:

root@marketing:~# crudini --get /gbin/structure.ini server__gigataxi_prod
_type
ServerDomainName
ServerHostName
ServerIP4
ServerSyncGbin
SrvCfgSync_Dirs2Git
SrvCfgSync_Enable
SrvCfgSync_RsyncFilters
SrvCfgSync_ShhRemote
ServerSSHport

I use Ubuntu 18.04/20.04

I cannot understand the reason.
It seems when I use old crudini 0.7 from machine apt package, but I am not sure.
Seems sometimes it happens on crudini 0.9.3 also.

Do you suppose the reason for such behavior?

thanks!

Parse issue in versions 0.8 and 0.9: AttributeError

In version 0.8 and 0.9 I get this error when running the following command. I do not get this in version 0.7

vendor/pixelb/crudini/crudini --get server/config.ini '' resources.db.params.host

Traceback (most recent call last):
File "vendor/pixelb/crudini/crudini", line 962, in
sys.exit(main())
File "vendor/pixelb/crudini/crudini", line 959, in main
return crudini.run()
File "vendor/pixelb/crudini/crudini", line 857, in run
preserve_case=preserve_case)
File "vendor/pixelb/crudini/crudini", line 639, in parse_file
conf = self._parse_file(filename, preserve_case=preserve_case)
File "vendor/pixelb/crudini/crudini", line 622, in _parse_file
conf = CrudiniConfigParser(preserve_case=preserve_case)
File "vendor/pixelb/crudini/crudini", line 202, in init
iniparse.change_comment_syntax('%;#', allow_rem=False)
AttributeError: 'module' object has no attribute 'change_comment_syntax'

Contents of config.ini file is

resources.db.params.host = localhost
resources.db.params.dbname = ks_caa_smoke
resources.db.params.username = ks
resources.db.params.password = Interoute
resources.db.params.charset = utf8

Can this be fixed soon?

Python 3 support

Hi there!

Just wondering if you had any plans to add Python 3 support?

I'm a bit of a newbie to Python so I tried turning the print, except and raise statements into functions which possibly got me most of the way there... until I came across issues with cStringIO and ConfigParser not being available.

Thanks for what you've done so far and thanks in advance if a Python 3 version is possible!

Parsing conf files where same param can be defined multiple times

Just wanted to draw your attention to ntp.conf

server 0.rhel.pool.ntp.org iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst

This is not an abstract example. I just tried to modify it using crudini, but I couldn't find a way to do it

works in bash, but not sh

crudini does NOT work in sh on my side

$ crudini --version
crudini 0.7

$ crudini --get /home/vagrant/.python-gitlab.cfg default url
https://gitlab.eng.xxxxxxx.com/`
$ sh
$ crudini --get /home/vagrant/.python-gitlab.cfg default url
File "/usr/local/bin/crudini", line 39
print str(e)
^
SyntaxError: invalid syntax
$ exit

Support nested sections

It would be nice if crudini supported nested sections, as for example in:

[system]
  inventory = 0x8492384
  [[software]]
     update = yes
     upgrade = no
  [[config]]
     foo = bar

When I run the command,I got the error!

Traceback (most recent call last):
File "./crudini", line 916, in
sys.exit(main())
File "./crudini", line 913, in main
return crudini.run()
File "./crudini", line 815, in run
self.mconf = self.parse_file('-', preserve_case=True)
File "./crudini", line 610, in parse_file
conf = self._parse_file(filename, preserve_case=preserve_case)
File "./crudini", line 594, in _parse_file
conf = CrudiniConfigParser(preserve_case=preserve_case)
File "./crudini", line 184, in init
iniparse.change_comment_syntax('%;#', allow_rem=False)
AttributeError: 'module' object has no attribute 'change_comment_syntax'

Single-token values without '=' and RHS

The MySQL ini file has a number of settings which are either present or absent - but have no value (e.g. [mysqld] - skip-external-locking, and [mysqldump] - quick, quote-names for just a few). There doesn't seem to be support for thes: it comes up with a parse error.

In addition - it reports parse-errors on !include ... lines which seem to be widespread in ini files too...

Win: msvcrt lock error

Traceback (most recent call last):
  File "./crudini", line 979, in <module>
    sys.exit(main())
  File "./crudini", line 975, in main
    return crudini.run()
  File "./crudini", line 869, in run
    preserve_case=preserve_case)
  File "./crudini", line 648, in parse_file
    not self.update)
  File "./crudini", line 165, in __init__
    self.lock()
  File "./crudini", line 96, in lock
    msvcrt.locking(self.fp, msvcrt.LK_LOCK, 1)
TypeError: an integer is required

Windows 10
python installed through choco install python2

choco install python2
python -m pip install --upgrade pip
pip install iniparse
python ./crudini --get example.ini '' global

python ./crudini --help and version work fine

section keys not displayed when values overlap with global defaults

I am trying to manipulate my Ansible hosts.ini files, which looks like this:

host1.example.com
host2.example.com
host3.example.com
host4.example.com

[group1]
host1.example.com
host2.example.com

[group2]
host3.example.com
host4.example.com

When I want to get all hosts (global items), I run the following command:

$ crudini --get hosts.ini ''
host1.example.com
host2.example.com
host3.example.com
host4.example.com

However, when I want to display the hosts in section group1, I do not get any output at all:

$ crudini --get hosts.ini 'group1'
$

If I modify the ini file to look like this:

host1.example.com
host2.example.com
host3.example.com
host4.example.com

[group1]
host1.example.com=1
host2.example.com=1

[group2]
host3.example.com=1
host4.example.com=1

and run the same command again I get the following output:

$ crudini --get hosts.ini 'group1'
host1.example.com
host2.example.com

Is it possible to get identical behavior for the default and the other sections?

I am running crudini-0.9-1.el7.noarch

Exception AttributeError: AttributeError("'NoneType' object has no attribute 'unlink'",) in <bound method LockedFile.__del__ of <__main__.LockedFile object at 0x26b8d50>> ignored

% tox
GLOB sdist-make: /tmp/crudini/setup.py
py26 create: /tmp/crudini/.tox/py26
py26 installdeps: iniparse
py26 inst: /tmp/crudini/.tox/dist/crudini-0.4.zip
py26 runtests: PYTHONHASHSEED='3324528470'
py26 runtests: commands[0] | /bin/bash -c cd tests && ./test.sh
Test 1 OK (line 32)
Exception AttributeError: AttributeError("'NoneType' object has no attribute 'unlink'",) in <bound method LockedFile.__del__ of <__main__.LockedFile object at 0x26b8d50>> ignored
Test 2 OK (line 39)

tox stopped on test2 and process run:

% strace -p 13320
^[[6~Process 13320 attached - interrupt to quit
select(0, NULL, NULL, NULL, {0, 677151}) = 0 (Timeout)
open(".test.ini.crudini.lck", O_RDONLY|O_CREAT|O_EXCL, 0) = -1 EEXIST (File exists)
select(0, NULL, NULL, NULL, {1, 0})     = 0 (Timeout)
open(".test.ini.crudini.lck", O_RDONLY|O_CREAT|O_EXCL, 0) = -1 EEXIST (File exists)
select(0, NULL, NULL, NULL, {1, 0})     = 0 (Timeout)
open(".test.ini.crudini.lck", O_RDONLY|O_CREAT|O_EXCL, 0) = -1 EEXIST (File exists)
select(0, NULL, NULL, NULL, {1, 0})     = 0 (Timeout)
open(".test.ini.crudini.lck", O_RDONLY|O_CREAT|O_EXCL, 0) = -1 EEXIST (File exists)
select(0, NULL, NULL, NULL, {1, 0})     = 0 (Timeout)
open(".test.ini.crudini.lck", O_RDONLY|O_CREAT|O_EXCL, 0) = -1 EEXIST (File exists)
select(0, NULL, NULL, NULL, {1, 0})     = 0 (Timeout)
open(".test.ini.crudini.lck", O_RDONLY|O_CREAT|O_EXCL, 0) = -1 EEXIST (File exists)
select(0, NULL, NULL, NULL, {1, 0})     = 0 (Timeout)
open(".test.ini.crudini.lck", O_RDONLY|O_CREAT|O_EXCL, 0) = -1 EEXIST (File exists)
% uname -a
Linux hp 3.15.1 #2 SMP Sun Jun 22 18:33:35 UTC 2014 x86_64 GNU/Linux
% cat /etc/issue
Debian GNU/Linux 7 \n \l

PIP install fails, no setup.py?

$ sudo pip install crudini
Downloading/unpacking crudini
Downloading crudini-0.3.tar.gz
Running setup.py egg_info for package crudini
Traceback (most recent call last):
File "", line 14, in
IOError: [Errno 2] No such file or directory: '/home/user/build/crudini/setup.py'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 14, in

IOError: [Errno 2] No such file or directory: '/home/user/build/crudini/setup.py'

support for editing krb.conf file

krb.conf file is mostly an ini file but it still have something that makes in incompatible with crudini:

[realms]
EXAMPLE.COM = {
  kdc = kerberos.bos.example.com
  kdc = kerberos.corp.example.com
  default_domain = EXAMPLE.COM
}

Is it possible to edit this file with crudini? If not is there a workaround?

Error when using 0.9 on Alpine

I am working with Alpine and it seems that 0.9 is the current version avialable on that platform. When I install it, I am getting the following error

File "/usr/bin/crudini", line 39
    print str(e)
             ^
 SyntaxError: invalid syntax

If it helps the version of python installed to 3.8.5

Function 'get' bug?

# 1: input file
# 2: Problem: 'get' for all doesn't gives all values: as.alma & av.alma are missing.
# 3-5: get works for the exact value.

~$ cat a.ini  # 1
alma = 12

[as]
alma = 12
korte = 15

[av]
alma = 12
~$ crudini --get --format=lines a.ini # 2
[ DEFAULT ] alma = 12
[ as ] korte = 15
[ av ]

~$ crudini --get a.ini "as" alma # 3
12
~$ crudini --get a.ini "av" alma # 4
12
~$ crudini --get a.ini "" alma # 5
12

Loop thru .ini sections possible ?

Hello !

Cannot imagine how to get list of sections in ini file. I just need to loop thru them using bash.
I see it is not implemented. Any advice/ workaround will be much appreciated.

Thank you for nice tool!

Vladimir

crudini is not case-preserving

# ./crudini --merge --format=ini example.ini  <<EOF
[general]
AAA=bbb
EOF  

# tail example.ini 

[non-sh-compat]
space name=val
útf8name=val
1num=val
ls;name=val


[general]
aaa = bbb

crudini can leave locks files in HA configurations

Actually crudini can potentially leave .lck files when is in HA configurations. If STONITH decides to shutdown a node when is running a crudini --get, a .lck file will remain in the file system.

I propose to extend --get with an unsafe parameter --no-lock to avoid the creation of the lock file. This non default parameter can behave properly with the default mode of --set (that is file_replace), but will cause problems with the non default --inplace option.

Crudini Win32x

Hello; Would it be possible to explain step by step how to compile or Crudini in Cygwin under Win32bits? I tried but was unsuccessful.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.