import traceback from ptp.PtpUsbTransport import PtpUsbTransport from ptp.PtpSession import PtpSession, PtpException from ptp import PtpValues ptpTransport = PtpUsbTransport(PtpUsbTransport.findptps()[0]) ptpSession = PtpSession(ptpTransport) vendorId = PtpValues.Vendors.STANDARD try: ptpSession.OpenSession() deviceInfo = ptpSession.GetDeviceInfo() vendorId = deviceInfo.VendorExtensionID # Read all the possible fstops fstops = ptpSession.GetDevicePropInfo( PtpValues.StandardProperties.F_NUMBER).Enumeration for fstop in fstops: ptpSession.SetFNumber(fstop) print "Capturing %i" % fstop ptpSession.InitiateCapture( objectFormatId=PtpValues.StandardObjectFormats.EXIF_JPEG) while True: evt = ptpSession.CheckForEvent(None) if evt.eventcode == PtpValues.StandardEvents.OBJECT_ADDED: break except PtpException, e: print "PTP Exception: %s" % PtpValues.ResponseNameById( e.responsecode, vendorId) except Exception, e:
for op in deviceInfo.CaptureFormats ]) print "ImageFormats:\n\t%s" % "\n\t".join([ PtpValues.ObjectFormatNameById(op, deviceInfo.VendorExtensionID) for op in deviceInfo.ImageFormats ]) print "Manufacturer: %s" % deviceInfo.Manufacturer print "Model: %s" % deviceInfo.Model print "DeviceVersion: %s" % deviceInfo.DeviceVersion print "SerialNumber: %s" % deviceInfo.SerialNumber print print "----------- PROPERTIES -----------" first = True for propertyId in deviceInfo.DevicePropertiesSupported: propertyInfo = ptpSession.GetDevicePropInfo(propertyId) if not first: print first = False print "PropertyCode: 0x%04x (%s)" % (propertyInfo.PropertyCode, PtpValues.PropertyNameById( propertyInfo.PropertyCode, deviceInfo.VendorExtensionID)) print "DataType: %s" % PtpValues.SimpleTypeDetailsById( propertyInfo.DataType)[0] print "GetSet: %s" % PtpValues.GetSetNameById( propertyInfo.GetSet, deviceInfo.VendorExtensionID) print "FactoryDefaultValue: %s" % propertyInfo.FactoryDefaultValue print "CurrentValue: %s" % propertyInfo.CurrentValue if propertyInfo.MinimumValue != None: