Jakub Trllo Posted March 27, 2019 Report Share Posted March 27, 2019 Hi, I'm trying out how to download images from notes but when I want call Location.get_url(note_component[component]), session crashes with: AttributeError: 'Symbol' object has no attribute 'get_url'. I've found out that "ftrack.server"'s Location accessor stays set to ftrack_api.symbol.NOT_SET. When I tried same code for "ftrack.unmanaged" it worked correctly. Can you help me what can be wrong on my side? Thanks! Link to comment Share on other sites More sharing options...
JPrydz Posted March 28, 2019 Report Share Posted March 28, 2019 Hi Jakub, Welcome to the forum. Is it possible for you provide the code for this? Regards, Johan Link to comment Share on other sites More sharing options...
Jakub Trllo Posted March 28, 2019 Author Report Share Posted March 28, 2019 Hi, I've actually tried API documentation part: ``` server_location = session.query( 'Location where name is "ftrack.server"' ).one() for note_component in note['note_components']: print 'Download URL: {0}'.format( server_location.get_url(note_component['component']) ) ``` Link to comment Share on other sites More sharing options...
JPrydz Posted March 29, 2019 Report Share Posted March 29, 2019 Hi Jakub, Can you provide a simplified code to show the issue? In case it contains sensitive information, please send it to support. Regards, Johan Link to comment Share on other sites More sharing options...
Jakub Trllo Posted March 29, 2019 Author Report Share Posted March 29, 2019 I've cut off all unnecessary parts of code and modified it to the most basic script that should work(i think): import ftrack_api session = ftrack_api.Session( auto_connect_event_hub=True, server_url='https://myapp.ftrackapp.com', api_key='xxx-xxx-xxx-xxx-xxx', api_user='my.user.name' ) server_location = session.query( 'Location where name is "ftrack.server"' ).one() # just pretend that note with component will be queried... note = session.query('Note').first() for note_component in note['note_components']: component = note_component['component'] download_url = server_location.get_url(component) # This is line where error is raised path = r'C:\Users\my.user.name\test' + component['file_type'] download_file(download_url, path) def download_file(url, path): r = requests.get(url, stream=True).content with open(path, 'wb') as f: f.write(r) Link to comment Share on other sites More sharing options...
Lorenzo Angeli Posted April 2, 2019 Report Share Posted April 2, 2019 Hi @Jakub Trllo, I've just tried the code you sent and cannot get to reproduce your issue. Here is what I've been doing and the code I've used. 1) I have manually created a note on a task from the web interface. 2) I have run the following code to add a component to the given note (please "note", that I have just one , so the query is quite simple). import ftrack_api session = ftrack_api.Session() server_location = session.query( 'Location where name is "ftrack.server"' ).one() note = session.query('Note').first() # get the only note I have in the system # Create component and name it "My file". component = session.create_component( '/path/to/an/image.png', data={'name': 'My file'}, location=server_location ) # Attach the component to the note. session.create( 'NoteComponent', {'component_id': component['id'], 'note_id': note['id']} ) session.commit() Once run this code I then run this other snippet : import ftrack_api session = ftrack_api.Session( auto_connect_event_hub=True, ) server_location = session.query( 'Location where name is "ftrack.server"' ).one() # just pretend that note with component will be queried... note = session.query('Note').first() for note_component in note['note_components']: component = note_component['component'] download_url = server_location.get_url(component) print download_url # I just print the path as the issue seems on retrieving it. When running the above code this is the result I'm getting: https://myserver.ftrackapp.com/component/get?id=d5d785dc-fdd0-4c6f-b7f9-54b3339ade81&username=myuser&apiKey=m1ap1key-m1ap1key-m1ap1key-m1ap1key-m1ap1key Hope it helps. L. Link to comment Share on other sites More sharing options...
Jakub Trllo Posted April 2, 2019 Author Report Share Posted April 2, 2019 Found out the mistake I've made because of you. I am using same session for all actions. Seems like not good idea when working with "ftrack.server" location, loose it's definition (probably on session.reset()?). Thanks Link to comment Share on other sites More sharing options...
Lorenzo Angeli Posted April 3, 2019 Report Share Posted April 3, 2019 Hi @Jakub Trllo glad to hear you had it sorted! If you can produce a piece of code that crashes I'd like you to send it to support for further checks if you don't mind Thanks a lot, and if there's anything else we can help out with, just let us know ! L. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.