You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both of the Python example files don't seem to work completely. Logging in, fetching nodes, getting account details, getting contacts, and even creating a folder works without any issues for me. However, attempting to traverse any nodes does not work. Every node, regardless of if it's the root node, an incoming share, or even if I login to a folder. I can get the node's name, but never any children.
I've also tried a very simplified threaded event listener pattern:
fromdotenvimportload_dotenvload_dotenv()
importosimportmegaimportthreadingclassListener(mega.MegaListener):
""" Custom listener for the Mega API, which handles API responses and errors. Attributes ---------- event : threading.Event An event to signal when our operations are complete. root_node : mega.MegaNode The root node after fetching nodes from the Mega API. results : mega.MegaRequest The results from the Mega API request. error : str Error message, if any error occurs while making a request to the Mega API. Methods ------- onRequestFinish(api, request, error): Callback function which is executed when the Mega API request is finished. """def__init__(self):
""" Initialize the Listener class with its attributes. """super().__init__()
self.event=threading.Event()
self.root_node=Noneself.results=Noneself.error=NonedefonRequestFinish(self, api, request, error):
""" Callback function which is executed when the Mega API request is finished. Parameters ---------- api : mega.MegaApi The Mega API instance. request : mega.MegaRequest The Mega API request. error : mega.MegaError The error, if any, from the Mega API request. """iferror.getErrorCode() !=mega.MegaError.API_OK:
self.error="Mega API error: "+error.getErrorString()
else:
ifrequest.getType() ==mega.MegaRequest.TYPE_LOGIN:
print(request)
api.fetchNodes()
elifrequest.getType() ==mega.MegaRequest.TYPE_FETCH_NODES:
print(request)
self.root_node=api.getRootNode()
self.event.set()
else:
self.results=request.copy()
self.event.set()
defmain():
""" Main function to demonstrate the usage of the Mega API. """# Create a MegaApi instance with the given application keyapi=mega.MegaApi("YOUR_APP_KEY")
# Use an event to signal when our operations are completelistener=Listener()
api.addListener(listener)
# Login to Megaapi.login(os.getenv("mega_email"), os.getenv("mega_password"))
listener.event.wait()
# Error handlingiflistener.error!=None:
raiseException(listener.error)
# Print the name and children of the root nodeprint(listener.root_node.getName())
print(listener.root_node.getChildren())
# Remove the listener from the Mega API instanceapi.removeListener(listener)
if__name__=="__main__":
main()
Running the above code I get the following output:
MegaNode::getChildren() always returns NULL unless used on a node returned MegaApi::authorizeNode according to the Doxygen docs. You would have to use MegaApi::getChildren(), but I don't know if that actually works as I'm on an older version using MegaApi::getFileFolderChildren()
Both of the Python example files don't seem to work completely. Logging in, fetching nodes, getting account details, getting contacts, and even creating a folder works without any issues for me. However, attempting to traverse any nodes does not work. Every node, regardless of if it's the root node, an incoming share, or even if I login to a folder. I can get the node's name, but never any children.
I've also tried a very simplified threaded event listener pattern:
Running the above code I get the following output:
Despite there being items in the root:
My build script is pretty straight forward.
And it's compiled using a container with the following Dockerfile:
I have also tried building with Python 3.9, but I get the same results.
The text was updated successfully, but these errors were encountered: