Exemple #1
0
    def sendSMS(self, number, text, masterKey, senderName):
        #Spedisco il messaggio: inizializzo il PreferenceManager
        #ed il CodingManager
        p = PreferenceManager.getInstance()
        cm = CodingManager.getInstance()

        #Se necessario, cerco il nome in rubrica
        #Inizializzo il sender e mando il messaggio
        senderName = senderName.title()
        if number.isdigit() == False:
            number = p.lookup(number)
        if Sender.getPlugins().has_key(senderName) == False:
            print "Sito "+senderName+" non riconosciuto."
        else:
            reg = {}
            s = Sender.getPlugins()[senderName]
            if s.requiresRegistration:
                try:
                    for i in s.requiresRegistration:
                        reg[i] = p.getAccount(senderName, i, masterKey)
                except PreferenceManagerError:
                    for i in s.requiresRegistration:
                        p.addAccount(i, cm.unicodeStdin(
                            raw_input("Immetti il dato "+i+": ")),
                                     senderName, masterKey)
                    for i in s.requiresRegistration:
                        reg[i] = p.getAccount(senderName, i, masterKey)
            s.send(number, text, reg)
            print "Spedito!"
Exemple #2
0
    def sendSMS(self, number, text, senderName):
        # Spedisco il messaggio: inizializzo il PreferenceManager
        # ed il CodingManager
        p = PreferenceManager.getInstance()
        cm = CodingManager.getInstance()

        masterKey = None
        if p.isEncryptionEnabled():
            keyValid = False
            while keyValid == False:
                masterKey = raw_input("Inserisci la Master Password:"******"Sito " + senderName + " non riconosciuto."
        else:
            reg = {}
            s = Sender.getPlugins()[senderName]
            if s.requiresRegistration:
                try:
                    for i in s.requiresRegistration:
                        reg[i] = p.getAccount(senderName, i, masterKey)
                except PreferenceManagerError:
                    for i in s.requiresRegistration:
                        p.addAccount(
                            i, cm.unicodeStdin(raw_input("Immetti il dato " + i + ": ")), senderName, masterKey
                        )
                    for i in s.requiresRegistration:
                        reg[i] = p.getAccount(senderName, i, masterKey)
            s.sendOne(number, text, reg)
            print "Spedito!"
Exemple #3
0
    def run(self):
        """Avvia questa interfaccia."""
        exitCode = 0
        try:
            p = PreferenceManager.getInstance()
            cm = CodingManager.getInstance()
            masterKey = None
            print "(Questo programma funziona anche dalla linea di comando, \
vedi LEGGIMI)"
            masterKey = None
            if p.isEncryptionEnabled():
                keyValid = False
                while keyValid == False:
                    masterKey = raw_input("Inserisci la Master Password:"******"Immetti il numero del destinatario e \
premi INVIO: ")
            number = cm.unicodeStdin(number)
            text = cm.unicodeStdin(
                raw_input("Immetti il testo e premi INVIO: "))
            print "Siti disponibili per l'invio:"
            plugins = Sender.getPlugins().keys()
            for i in plugins:
                print i
            print "Immetti il nome del sito. Le maiuscole non fanno differenza."
            sender = raw_input("Premi solo INVIO per "+plugins[0]+":")
            sender = cm.unicodeStdin(sender)
            if (sender == ""):
                sender = plugins[0]
            proxy = ""
            if p.isProxyEnabled():
                print "Proxy attualmente configurato: " + p.getProxy()
                proxy = raw_input("(INVIO per confermare, \"no\" per " +
                    "disabilitare o nuovo indirizzo:)")
                if proxy == "no":
                    p.unsetProxy()
                elif proxy != "":
                    p.setProxy(proxy)
            else:
                print "Immetti l'indirizzo e la porta del proxy:"
                proxy = raw_input("(se non sai cosa sono o non li usi premi INVIO)")
                if proxy != "":
                    p.setProxy(proxy)
            if p.isProxyEnabled() == True:
                os.environ["http_proxy"] = p.getProxy()
            self.sendSMS(number, text, masterKey, sender)
        except NotFoundError, e:
            print cm.encodeStdout(e.__str__())
            exitCode = 1
Exemple #4
0
#!/usr/bin/env python

# TODO -- integrate the importer in pyMoioSMS

from ConfigParser import ConfigParser, NoSectionError
from moio.PreferenceManager import PreferenceManager

question = "Do you want to import MoioSMS 2 contacts? (Y/n) --> "
answer = raw_input(question)
if answer.lower() in ('', 'y'):

    pyMoioSMSfile = PreferenceManager.getConfigFileName(PreferenceManager.getInstance())
    MoioSMSfile = pyMoioSMSfile.replace("py", "")

    # Read MoioSMS contacts if MoioSMSfile exists
    try: file(MoioSMSfile)
    except IOError: quit("The '%s' file doesn't exist" % MoioSMSfile)
    MoioSMSconfig = ConfigParser()
    MoioSMSconfig.optionxform = str
    MoioSMSconfig.read(MoioSMSfile)
    try: contacts = MoioSMSconfig.items('contacts')
    except NoSectionError: quit("The is no such contact stored in your MoioSMS2 file!")

    # Write contacts into pyMoioSMS configuration file
    try: file(pyMoioSMSfile)
    except IOError: quit("The '%s' file doesn't exist" % pyMoioSMSfile)
    pyMoioSMSconfig = ConfigParser()
    pyMoioSMSconfig.optionxform = str
    pyMoioSMSconfig.read(pyMoioSMSfile)
    pyMoioSMSconfig.add_section('contacts') if not pyMoioSMSconfig.has_section('contacts') else None
    for key, value in contacts:
Exemple #5
0
 def run(self):
     """Avvia questa interfaccia."""
     na = len(sys.argv) - 1
     exitCode = 0
     p = PreferenceManager.getInstance()
     cm = CodingManager.getInstance()
     try:
         if na == 1:
             # Un solo argomento, lista rubrica o help
             arg1 = cm.unicodeArgv(sys.argv[1])
             if arg1 == "-m" or arg1 == "--mostra":
                 for name, number in p.getContacts().iteritems():
                     print cm.encodeStdout(name) + ": " + cm.encodeStdout(number)
             else:
                 HelpUI.getInstance().run()
         elif na == 2:
             # Due argomenti, numero e testo
             arg1 = cm.unicodeArgv(sys.argv[1])
             arg2 = cm.unicodeArgv(sys.argv[2])
             self.sendSMS(arg1, arg2, Sender.getPlugins().keys()[0])
         elif na == 3:
             # Tre argomenti. Tre casi: "-a nome numero"
             # oppure "numero testo sender"
             arg1 = cm.unicodeArgv(sys.argv[1])
             arg2 = cm.unicodeArgv(sys.argv[2])
             arg3 = cm.unicodeArgv(sys.argv[3])
             if arg1 == "-a" or arg1 == "--add":
                 p.addContact(arg2, arg3)
                 print "Aggiunto!"
             else:
                 if p.isProxyEnabled() == True:
                     os.environ["http_proxy"] = p.getProxy()
                 self.sendSMS(arg1, arg2, arg3)
         elif na == 4:
             # numero testo -p proxy
             arg1 = cm.unicodeArgv(sys.argv[1])
             arg2 = cm.unicodeArgv(sys.argv[2])
             arg3 = cm.unicodeArgv(sys.argv[3])
             arg4 = cm.unicodeArgv(sys.argv[4])
             if arg3 == "-p" or arg3 == "--proxy":
                 if arg4 != "no":
                     p.setProxy(arg4)
                 else:
                     p.unsetProxy()
                 if p.isProxyEnabled() == True:
                     os.environ["http_proxy"] = p.getProxy()
                 self.sendSMS(arg1, arg2, Sender.getPlugins().keys()[0])
             else:
                 HelpUI.getInstance().run()
         elif na == 5:
             # numero testo sender -p proxy
             arg1 = cm.unicodeArgv(sys.argv[1])
             arg2 = cm.unicodeArgv(sys.argv[2])
             arg3 = cm.unicodeArgv(sys.argv[3])
             arg4 = cm.unicodeArgv(sys.argv[4])
             arg5 = cm.unicodeArgv(sys.argv[5])
             if arg4 == "-p" or arg4 == "--proxy":
                 if arg5 != "no":
                     p.setProxy(arg5)
                 else:
                     p.unsetProxy()
                 if p.isProxyEnabled() == True:
                     os.environ["http_proxy"] = p.getProxy()
                 self.sendSMS(arg1, arg2, arg3)
             else:
                 HelpUI.getInstance().run()
         else:
             HelpUI.getInstance().run()
     except NotFoundError, e:
         print cm.encodeStdout(e.__str__())
         exitCode = 1