pyOneNote icon indicating copy to clipboard operation
pyOneNote copied to clipboard

`pyonenote` not working from the command line

Open Coniferish opened this issue 1 year ago • 14 comments

I installed pyonenote via pip install pyonenote and tried running pyonenote -f example-docs/QuickNotes.one and got the following error:

Traceback (most recent call last):
  File ".../pyonenote", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File ".../site-packages/pyOneNote/Main.py", line 97, in main
    sys.exit("File: %s doesn't exist", args.file)
TypeError: exit expected at most 1 argument, got 2

I also tried cloning the repo, changing the sys.exit line to and f-string, but still got an error:

$ python Main.py -f QuickNotes.one
Traceback (most recent call last):
  File ".../pyOneNote/pyOneNote/Main.py", line 104, in <module>
    main()
  File ".../pyOneNote/pyOneNote/Main.py", line 100, in main
    process_onenote_file(file, args.output_dir, args.extension, args.json)
  File ".../pyOneNote/pyOneNote/Main.py", line 28, in process_onenote_file
    document = OneDocment(file)
               ^^^^^^^^^^^^^^^^
  File ".../pyOneNote/lib/python3.11/site-packages/pyOneNote/OneDocument.py", line 11, in __init__
    self.root_file_node_list = FileNodeList(file, self, self.header.fcrFileNodeListRoot)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../pyOneNote/lib/python3.11/site-packages/pyOneNote/FileNode.py", line 16, in __init__
    file.seek(file_chunk_reference.stp)
ValueError: cannot fit 'int' into an offset-sized integer

Coniferish avatar Aug 23 '23 21:08 Coniferish

Can you share the sample? or if it is on VirusTotal, share the SHA256? Without having the sample it is very hard to debug. Most probably the .one file contains a structure that is not supported by pyOneNote... Did you test with another .one document?

DissectMalware avatar Aug 28 '23 16:08 DissectMalware

I'm getting a message saying the file type (.one) isn't supported when I try to add it here. And no, I didn't try with another file since I created this file for testing.

Coniferish avatar Aug 28 '23 18:08 Coniferish

@DissectMalware, how can I send the file to you?

Coniferish avatar Sep 01 '23 17:09 Coniferish

@DissectMalware Hello, thank you for this tool. I got the same error: 'ValueError: cannot fit 'int' into an offset-sized integer' for a different sample, that can be obtained from VT (sha256: f770bf655720539c6171e77758383744be087b480a3f70256cc5043c489e529e). Hope this helps.

Traceback (most recent call last): File "Main.py", line 104, in main() File "Main.py", line 100, in main process_onenote_file(file, args.output_dir, args.extension, args.json) File "Main.py", line 28, in process_onenote_file document = OneDocment(file) File ".../site-packages/pyOneNote/OneDocument.py", line 11, in init self.root_file_node_list = FileNodeList(file, self, self.header.fcrFileNodeListRoot) File ".../site-packages/pyOneNote/FileNode.py", line 23, in init fragment = FileNodeListFragment(file, document, section_end) File ".../site-packages/pyOneNote/FileNode.py", line 38, in init node = FileNode(file, document) File ".../site-packages/pyOneNote/FileNode.py", line 181, in init self.children.append(FileNodeList(file, self.document, self.data.ref)) File ".../site-packages/pyOneNote/FileNode.py", line 23, in init fragment = FileNodeListFragment(file, document, section_end) File ".../site-packages/pyOneNote/FileNode.py", line 38, in init node = FileNode(file, document) File ".../site-packages/pyOneNote/FileNode.py", line 181, in init self.children.append(FileNodeList(file, self.document, self.data.ref)) File ".../site-packages/pyOneNote/FileNode.py", line 28, in init file.seek(fragment.nextFragment.stp) ValueError: cannot fit 'int' into an offset-sized integer

ljuturu avatar Sep 13 '23 05:09 ljuturu

I got the same error. Here is a zipped example file to trigger this: Schnelle Notizen.one.zip

marph91 avatar Apr 02 '24 18:04 marph91

I got the same error. Here is a zipped example file to trigger this: Schnelle Notizen.one.zip

I copy/paste the file on my computer and I don't have any problem (your file size is much larger than my copy). I am trying to understand this library to fork it (no news of owner), you can contact me at [email protected] if you are interested to this

Kev744 avatar Apr 04 '24 16:04 Kev744

@Kev744 at the moment I am swamped with my other responsibilities but try to help if something is blocking you from contributing...

DissectMalware avatar Apr 04 '24 18:04 DissectMalware

I copy/paste the file on my computer and I don't have any problem (your file size is much larger than my copy).

It might be caused by a different python version (or different module version). I'm using Python 3.11.8.

marph91 avatar Apr 04 '24 18:04 marph91

@Kev744 at the moment I am swamped with my other responsibilities but try to help if something is blocking you from contributing...

No problem before the responsabilities. Thanks, How can I contact you ?

It might be caused by a different python version (or different module version). I'm using Python 3.11.8.

I am using Python 3.9.12 and module 0.0.2, but the main source doesn't probably come from the Python and module because when I use your file (it doesn't work also), I need to copy/paste the file with OneNote (Move or Copy) in order to work, maybe OneNote version, what version you use for comparing with mine ? I am using Microsoft® OneNote® for Microsoft 365 MSO (Version 2402)

Kev744 avatar Apr 04 '24 19:04 Kev744

what version you use for comparing with mine ?

I use the web version at https://www.onenote.com/notebooks (couldn't find a specific version there). I don't use it actively yet. Just trying out the functions and seeing what tools around are available.

marph91 avatar Apr 05 '24 15:04 marph91

Check it : https://learn.microsoft.com/en-us/openspecs/office_file_formats/ms-onestore/93a9831c-553f-4547-9d44-b8d6f879aaaa#Appendix_A_11

The code should to be updated for OneNote Online unfortunately...

Kev744 avatar Apr 05 '24 18:04 Kev744

Thanks for looking into it! Just for understanding: Is it

<9> Section 2.7.2: Microsoft OneNote Online generates an Extended GUID not following this algorithm

?

marph91 avatar Apr 05 '24 21:04 marph91

Thanks for looking into it! Just for understanding: Is it

<9> Section 2.7.2: Microsoft OneNote Online generates an Extended GUID not following this algorithm

?

Yes it is.

Kev744 avatar Apr 05 '24 22:04 Kev744

Actually it's not just the different GUID, but for exports from OneNote Online there is at least one more layer that needs to be decoded. I. e. FSSHTTP. I managed to write a parser for this layer (at least for my test files), but I stopped, because it takes too much time.

The only alternative for parsing OneNote Online files seems to be https://github.com/msiemens/onenote.rs. I didn't try it yet, though.

marph91 avatar May 12 '24 15:05 marph91