[Gambas-user] gambas Disk Management
Brian G
brian at westwoodsvcs.com
Sat Nov 26 06:37:22 CET 2022
----- On Nov 25, 2022, at 8:54 PM, Brian G brian at westwoodsvcs.com wrote:
> ----- On Nov 25, 2022, at 2:52 PM, Christof Thalhofer chrisml at deganius.de wrote:
>
>> Am 25.11.22 um 21:56 schrieb Fabien Bodard:
>>
>>> New version
>>
>> This and the version before was bounced by all Gmail servers. Please
>> hide it.
>>
>> Alles Gute
>>
>> Christof Thalhofer
>>
>> --
>> Dies ist keine Signatur
>>
>>
>>
>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
> This is a great tool.
>
> Question : is it possible to identify NSF mounted disks as well using DBUS?
>
> Failure is the key to success;
> each mistake teaches us something" .. Morihei Ueshiba
> Brian G
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
Hi also your section that picks up the disk ID value currently picks up the length
When I changed it to
Private Function id_Read() As String
Dim s As String
Try s = Quote(Dbus[$sBus & $sApplication][$sMyPath, $sBaseInterface & "Drive"].Id)
If Error Then s = ""
Return s
End
It still fails to see the id,
I include a small script I use to identify disks, it does get the Disk ID
I hope this helps.
++++++++++++++++++++++++++
#!/usr/bin/env gbs3
' Gambas Script File Created 11/26/2022 05:27:25.988
use "gb.dbus","gb.xml"
Public Sub main()
Dim vManaged As Variant[]
Dim aList As Collection
Dim sXml As String
Dim xDevices As New XmlDocument
Dim xNodes As XmlNode[]
Dim AppName As String = "system://org.freedesktop.UDisks2"
Dim DevPath As String = "/org/freedesktop/UDisks2/block_devices"
Dim DrivePath As String = "/org/freedesktop/UDisks2/drives"
Dim DrIface As String = "org.freedesktop.UDisks2.Drive"
Dim Iface As String = "org.freedesktop.UDisks2.Block"
Dim devs As New String[]
Dim Drives As New String[]
sXml = DBus[AppName]._Introspect(DevPath)
Print "XML Devices\n"; sXml
xDevices.fromstring(sXml)
xNodes = xDevices.Root.Children
Print "Device List"
For Each pNode As XmlNode In xNodes
'Print pNode.Name
If pNode.name <> "node" Then Continue
For Each elm As Variant In pNode.attributes
If Not (elm.value Like "Loop*") Then devs.Add(elm.value)
Next
Next
For Each s As String In devs.Sort()
'Dim dConfig As Variant[] = DBus[AppName][DevPath &/ s, Iface].Configuration
Print Left(s & String(30, " "), 30), Format(DBus[AppName][DevPath &/ s, Iface].Size, "############0"), DBus[AppName][DevPath &/ s, Iface].Id, DBus[AppName][DevPath &/ s, Iface].IdUsage;;
Print DBus[AppName][DevPath &/ s, Iface].IdType, (DBus[AppName][DevPath &/ s, Iface].Device).tostring()
Next
sXml = DBus[AppName]._Introspect(DrivePath)
Print "XML Devices\n"; sXml
xDevices.fromstring(sXml)
xNodes = xDevices.Root.Children
Print "Device List"
For Each pNode As XmlNode In xNodes
'Print pNode.Name
If pNode.name <> "node" Then Continue
For Each elm As Variant In pNode.attributes
If Not (elm.value Like "Loop*") Then Drives.Add(elm.value)
Next
Next
For Each s As String In Drives.Sort()
'Dim dConfig As Variant[] = DBus[AppName][DevPath &/ s, Iface].Configuration
Print Left(s & String(20, " "), 20), Format(DBus[AppName][DrivePath &/ s, drIface].Size, "############0"), "Optical:"; DBus[AppName][DrivePath &/ s, DrIface].Optical, "Media:"; DBus[AppName][DrivePath &/ s, DrIface].Media;;
Print "Model:"; DBus[AppName][DrivePath &/ s, DrIface].Model, "Removable:"; DBus[AppName][DrivePath &/ s, DrIface].Removable, "Connected:"; DBus[AppName][DrivePath &/ s, DrIface].ConnectionBus
Next
QUIT 0
catch
Print error.text&"\n" & error.where
End
++++++++++++++++++++++++++++++++++++++
"Failure is the key to success;
each mistake teaches us something" .. Morihei Ueshiba
Brian G
More information about the User
mailing list