Jump to content

Heyo, so I am trying to create a symlink between two folders with a python script but I've hit a dead end where I get the following error:

Quote

OSError: [Errno 95] Operation not supported: '/mnt/atlantis/101_My_Test_Name/Foo_Shot/name01' -> '/mnt/endeavour/101_My_Test_Name/Foo_Shot/name01'

I've seen around that it might be related to permission, but as far as I know that should not be the case. The shares mounted in mnt are mounted with 777 permissions and the folders created by my script are also created with 777 permission. Anyone got any ideas, here be the code:

def createProjectDir(name,projectname,shotname,ftype):
    #create a directory, with options to create the symlink setup I want

    temp = projectname + '/' + shotname
    dirs = glob.glob(projdir + '/' + temp)
    dir = ''
    target = projdir + '/' + temp + '/' + name

    if name in dirs:
        print('Link/folder already exists, stopping')
    else:
        if ftype == 'cache':
            dir = cachedir + '/' + temp + '/' + name
            os.makedirs(dir,mode=777)
        elif ftype == 'render':
            dir = renderdir + '/' + temp + '/' + name
            os.makedirs(dir,mode=777)
        elif ftype == 'project':
            dir = projdir + '/' + temp + '/' + name
            os.makedirs(dir,mode=777)

        os.symlink(dir, target, target_is_directory=True)

Any help is greatly appreciated, still kind of new to this python business.
Thanks!

A VFX artist dabbling in the dark arts of programming in his spare time

Link to comment
https://linustechtips.com/topic/1248616-error-while-creating-symlink-python/
Share on other sites

Link to post
Share on other sites

Can you manually create the link in the terminal?

 

ln -s <source_file_directory> <link_file_directory>

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to post
Share on other sites

A symlink can only be created with a path that doesn't exist, but your code seems to create dir before linking it. If you just remove the os.makedirs calls then (assuming the parent exists) I think it should work.

 

Also, target_is_directory is ignored on non-windows platforms according to the docs, so I don't think you need that.

HTTP/2 203

Link to post
Share on other sites

Aight, so it turns out that by default samba shares does not allow symlink creation on them unless you are using SMB version 3.0 or higher and it seems that I am not (Not explicitly setting the version number so my linux workstation and the server are negotiating some version behind the scenes). What seems to have fixed it however is adding "mfsymlinks" to the mount command, making the share use "Minshall+French symlinks", whatever that means xD

 

Seems to be working now for the most part, thanks guys!

 

2 hours ago, colonel_mortis said:

A symlink can only be created with a path that doesn't exist, but your code seems to create dir before linking it. If you just remove

the os.makedirs calls then (assuming the parent exists) I think it should work.

 

Also, target_is_directory is ignored on non-windows platforms according to the docs, so I don't think you need that.

Huh, did not know about the target_is_directory being exclusive to windows, thanks for that one!
The makedirs command is to create the folder that I am linking to. The thought being that I have multiple shares for different things, one for project files, one for caches and one for my 3D renders and then create one folder that has links to all of that projects folders on all the other shares so I don't have to go around digging so much. So the makedirs command is just creating the folder I want to link to

13 hours ago, vorticalbox said:

Can you manually create the link in the terminal?

 

ln -s <source_file_directory> <link_file_directory>

No I could not. Only tested making links in terminal and with a test python script on my desktop, never tested in on my mounted shares.

 

A VFX artist dabbling in the dark arts of programming in his spare time

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×