from gi.repository import UDisks
from gi.repository import GLib
import sys
import os
import time

client = UDisks.Client.new_sync(None)
dev_t = os.stat(sys.argv[1]).st_rdev
block = client.get_block_for_dev(dev_t)
fs = client.get_object(block.get_object_path()).get_property('filesystem')

if len(sys.argv) > 2:
    # works
    print('calling through GDBusProxy')
    fs.Mount(('(a{sv})'), {})
    time.sleep(1)
    fs.Unmount(('(a{sv})'), {})
else:
    # fails: 
    print('calling through gdbus-codegen glue')
    fs.call_mount_sync(GLib.Variant('a{sv}', {}), None)
    time.sleep(1)
    fs.call_unmount_sync(GLib.Variant('a{sv}', {}), None)
