Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
madum31 opened this issue Jul 4, 2023 · 0 comments
Open

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

madum31 opened this issue Jul 4, 2023 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@madum31
Copy link

madum31 commented Jul 4, 2023

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

@Prayag2 Prayag2 added the bug Something isn't working label Dec 17, 2023
@Prayag2 Prayag2 added this to the v2.3.0 milestone Dec 17, 2023
@Prayag2 Prayag2 changed the title import non existing folder with "--force" option [BUG] Importing fails if parent directories do not exist Dec 17, 2023
@Prayag2 Prayag2 changed the title [BUG] Importing fails if parent directories do not exist [Bug] Importing fails if parent directories do not exist May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants