(2014-04-22, 21:59)takoi Wrote: [ -> ] (2014-04-21, 21:21)Anthirian Wrote: [ -> ]I have done some research and it appears that it is not possible to stat an absolute smb path such as 'smb://path/to/videos' using os.statvfs(), both while it is mounted and while it is not. Apparently this has to do with the way Linux handles mounted drives.
You can, when mounted. You obviously can't stat random urls though.
Check if pysmb support it.
Unfortunately this is not that obvious to me, being a bit of a beginner with Linux. Maybe you could help me understand?
Below is a snippet of the logs produced by the current code, while the 'E' share is mounted via SMB both in Linux itself and in XBMC by adding a network location.
Code:
19:44:10 T:140102252599040 NOTICE: XBMC File Cleaner: XBMC File Cleaner version 3.2.1 loaded.
19:44:10 T:140102252599040 NOTICE: XBMC File Cleaner: Starting cleaning routine.
19:44:10 T:140102252599040 NOTICE: XBMC File Cleaner: Checking for disk space on path: 'smb://GEERT/E/'
19:44:10 T:140102252599040 NOTICE: XBMC File Cleaner: We are checking disk space from a non-Windows file system
19:44:10 T:140102252599040 ERROR: XBMC File Cleaner: Could not check disk space. Access denied.
19:44:10 T:140102252599040 NOTICE: XBMC File Cleaner: Error accessing 'smb://GEERT/E/': OSError(2, 'No such file or directory')
19:44:10 T:140102252599040 NOTICE: XBMC File Cleaner: Free space: 100.00%
19:44:10 T:140102252599040 NOTICE: XBMC File Cleaner: No cleaning required
19:44:11 T:140103384143744 NOTICE: Samba is idle. Closing the remaining connections
I found out
here and
here that in order to access the share over in the terminal I have to use Linux' internal mount path (see below for the one Linux Mint uses) instead of the path XBMC uses for the file's location.
Code:
/run/user/1000/gvfs/smb-share:server=geert,share=e
When I use this internal mount path, I get the following log.
Code:
20:17:28 T:140102974043904 NOTICE: XBMC File Cleaner: XBMC File Cleaner version 3.2.1 loaded.
20:17:28 T:140102974043904 NOTICE: XBMC File Cleaner: Starting cleaning routine.
20:17:28 T:140102974043904 NOTICE: XBMC File Cleaner: Checking for disk space on path: '/run/user/1000/gvfs/smb-share:server=geert,share=e'
20:17:28 T:140102974043904 NOTICE: XBMC File Cleaner: We are checking disk space from a non-Windows file system
20:17:28 T:140102974043904 NOTICE: XBMC File Cleaner: Hard disk check results:
20:17:28 T:140102974043904 NOTICE: XBMC File Cleaner: Bytes free: 37,350,150
20:17:28 T:140102974043904 NOTICE: XBMC File Cleaner: Bytes total: 244,189,695
20:17:28 T:140102974043904 NOTICE: XBMC File Cleaner: Free space: 15.30%
20:17:28 T:140102974043904 NOTICE: XBMC File Cleaner: No cleaning required
20:19:03 T:140103384143744 NOTICE: Samba is idle. Closing the remaining connections
As you can see, disk space checks work correctly. The only thing that is a bit strange is the fact that my 1 TB drive is recognized to be only 244 GB in size. The percentage of free space however is in fact correct.
Code:
20:29:45 T:5232 NOTICE: XBMC File Cleaner: Starting cleaning routine.
20:29:45 T:5232 NOTICE: XBMC File Cleaner: Checking for disk space on path: 'E:\\'
20:29:45 T:5232 NOTICE: XBMC File Cleaner: We are checking disk space from a Windows file system
20:29:45 T:5232 NOTICE: XBMC File Cleaner: The path to check is 'E:\\'
20:29:45 T:5232 NOTICE: XBMC File Cleaner: We are dealing with local paths
20:29:45 T:5232 NOTICE: XBMC File Cleaner: Converting path to unicode for disk space checks
20:29:45 T:5232 NOTICE: XBMC File Cleaner: New path: u'E:\\'
20:29:45 T:5232 NOTICE: XBMC File Cleaner: Hard disk check results:
20:29:45 T:5232 NOTICE: XBMC File Cleaner: Bytes free: 152,961,269,760
20:29:45 T:5232 NOTICE: XBMC File Cleaner: Bytes total: 1000,200,990,720
20:29:45 T:5232 NOTICE: XBMC File Cleaner: Free space: 15.29%
When I run the checks from my local Windows machine containing the media files, checks run just fine. The free disk space percentage matches the one determined via SMB.
Thanks for the tip about pysmb though, I will look into that. Does this support NFS too? These are the two main networking protocols my addon needs to support.
(2014-04-22, 22:02)Martijn Wrote: [ -> ]Anything useful in this?
http://mirrors.xbmc.org/docs/python-docs...mcvfs.html
I'm afraid not. I assumed the Stat class would help me with this, but it lacks a method to check the amount of space currently used/free. It only has a method for determining the size of a folder, which is only half the solution.