Exemple #1
0
def main():
    state_machine = gammu.StateMachine()
    if len(sys.argv) == 2:
        state_machine.ReadConfig(Filename=sys.argv[1])
    else:
        state_machine.ReadConfig()
    state_machine.Init()

    # For calendar entry

    # Read entry from phone
    entry = state_machine.GetNextCalendar(Start=True)

    # Convert it to vCard
    vc_entry = gammu.EncodeVCALENDAR(entry)
    ic_entry = gammu.EncodeICALENDAR(entry)

    # Convert it back to entry
    print(gammu.DecodeVCS(vc_entry))
    print(gammu.DecodeICS(ic_entry))

    # For todo entry

    # Read entry from phone
    entry = state_machine.GetNextToDo(Start=True)

    # Convert it to vCard
    vt_entry = gammu.EncodeVTODO(entry)
    it_entry = gammu.EncodeITODO(entry)

    # Convert it back to entry
    print(gammu.DecodeVCS(vt_entry))
    print(gammu.DecodeICS(it_entry))

    # For memory entry

    # Read entry from phone
    entry = state_machine.GetNextMemory(Start=True, Type='ME')

    # Convert it to vCard
    vc_entry = gammu.EncodeVCARD(entry)

    # Convert it back to entry
    print(gammu.DecodeVCARD(vc_entry))
    def test_todo(self):
        entry = gammu.ReadBackup(os.path.join(TEST_DIR, '02.vcs'))['ToDo'][0]

        # Convert it to vCard
        vt_entry = gammu.EncodeVTODO(entry)
        it_entry = gammu.EncodeITODO(entry)

        # Convert it back to entry
        entry2 = gammu.DecodeVCS(vt_entry)
        entry3 = gammu.DecodeICS(it_entry)

        self.assertEqual(entry2['Type'], entry3['Type'])
    def test_calendar(self):
        entry = gammu.ReadBackup(os.path.join(TEST_DIR,
                                              'rrule.ics'))['Calendar'][0]

        # Convert it to vCard
        vc_entry = gammu.EncodeVCALENDAR(entry)
        ic_entry = gammu.EncodeICALENDAR(entry)

        # Convert it back to entry
        entry2 = gammu.DecodeVCS(vc_entry)
        entry3 = gammu.DecodeICS(ic_entry)

        self.assertEqual(entry2['Type'], entry3['Type'])
Exemple #4
0
    sm.ReadConfig(Filename=sys.argv[1])
else:
    sm.ReadConfig()
sm.Init()

# For calendar entry

# Read entry from phone
entry = sm.GetNextCalendar(Start=True)

# Convert it to vCard
vc_entry = gammu.EncodeVCALENDAR(entry)
ic_entry = gammu.EncodeICALENDAR(entry)

# Convert it back to entry
entry2 = gammu.DecodeVCS(vc_entry)
entry3 = gammu.DecodeICS(ic_entry)

# For todo entry

# Read entry from phone
entry = sm.GetNextToDo(Start=True)

# Convert it to vCard
vt_entry = gammu.EncodeVTODO(entry)
it_entry = gammu.EncodeITODO(entry)

# Convert it back to entry
entry2 = gammu.DecodeVCS(vt_entry)
entry3 = gammu.DecodeICS(it_entry)