Skip to content

[Bug] Importing fails if parent directories do not exist #89

Description

@madum31

Hi,

I found this tool as best one to satisfy goals I have to achieve:

  • save (export) a Plasma 4 current environment's settings (CentOS 7)
  • restore (import) the exported .knsv file as generic for any default user on many computers
  • operate import inside /etc/profile.d/ process as konsave_import.sh
  • all done through command line process

Unfortunately when importing into non existant destination folders, the "konsave -i file.knsv" command failed to create them:
i.e. :

Konsave: Importing profile. It might take a minute or two...
Konsave: Importing "gtk-2.0"...
Konsave: Importing "conf.yaml"...
Konsave: Importing "dolphin"...
Konsave: [Errno 2] No such file or directory: '/home/acme/.kde/share/apps/dolphin'
Please check the log at /home/acme/.cache/konsave_log.txt for more details.
Konsave: Importing "kate"...
Konsave: [Errno 2] No such file or directory: '/home/acme/.kde/share/apps/kate'
Please check the log at /home/acme/.cache/konsave_log.txt for more details.
Konsave: Importing "konqueror"...
Konsave: [Errno 2] No such file or directory: '/home/acme/.kde/share/apps/konqueror'
Please check the log at /home/acme/.cache/konsave_log.txt for more details.
Konsave: Importing "konsole"...
Konsave: [Errno 2] No such file or directory: '/home/acme/.kde/share/apps/konsole'
Please check the log at /home/acme/.cache/konsave_log.txt for more details.
Konsave: Importing "dolphinrc"...
Konsave: [Errno 2] No such file or directory: '/home/acme/.kde/share/config/dolphinrc'
Please check the log at /home/acme/.cache/konsave_log.txt for more details.

I didn't found that the "--force" option was available for import.
So I added it in the func.py module file
replacing :

def import_profile(path)

     ../..
     
        log(f'Importing "{entry}"...')
        if os.path.exists(source):
            if os.path.isdir(source):
                copy(source, dest)
            else:
                shutil.copy(source, dest)

by:

def import_profile(path, force)

     ../..
     
        log(f'Importing "{entry}"...')
        if os.path.exists(source):
            if os.path.isdir(source):
                if force:
                    mkdir(os.path.dirname(dest))
                copy(source, dest)
            else:
                if force:
                    mkdir(os.path.dirname(dest))
                shutil.copy(source, dest)
and in __main__.py:
elif args.import_profile:
    import_profile(args.import_profile)
by:
elif args.import_profile:
    import_profile(args.import_profile, args.force)

And I don't have any resultant errors having now all my default environment settings restored for any new user's first connection.

Hope this will help for a new release.

regards,
Martial

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions