Commit c23ff3c2 authored by putro's avatar putro

fix after merge

parent e93eeebb
......@@ -13,6 +13,7 @@ import gpgfuncts
import easygui
import string
import subprocess
import optparse
class bcolors:
......@@ -223,11 +224,10 @@ class MixError(Exception):
pass
def sendMixMsg(dest, msg, subj="subject", test=False):
def sendMixMsg(dest, msg, subj="subject", test=False, chain=""):
""" send msg through a local mixmaster client """
args = [config['options']['mixmaster'], '--mail', '--to=' + dest, '--subject=' + subj, '--copies=1']
print "\nChoose remailer chain used to send the message to %s\n" % dest
chooseChain()
chooseChain(chain=chain)
args.append('--chain=' + ','.join(config['remailer_chain']))
try:
......@@ -236,11 +236,16 @@ def sendMixMsg(dest, msg, subj="subject", test=False):
if err.find('Error') >= 0:
raise MixError('Mixmaster process returned the following error: ' + str(err) + '. Sending failed.')
config['last_message'] = "OK, succesfully sent email"
except OSError: # usally means that mixmaster could not be executed
except OSError: # usually means that mixmaster could not be executed
raise MixError('Could not find mixmaster binary.')
<<<<<<< HEAD
def writeMessage():
=======
def writeMessage(subject="", recipient="", text="", test=0):
>>>>>>> added command line option for testing nyms
"""
Create a message to be sent from nym
The message has to be sent through a remailer chain
......@@ -250,6 +255,7 @@ def writeMessage():
config['last_message'] = "ERROR - select your nym, actual selection HAS NOT a secret key"
menu()
<<<<<<< HEAD
while True:
subject = askSomething('Insert message subject: ')
if isAscii(subject):
......@@ -260,24 +266,41 @@ def writeMessage():
continue
recipient = raw_input("Insert recipient email address or newsgroup name: ")
=======
if subject == "":
while True:
subject = askSomething('Insert message subject: ')
if isAscii(subject):
break
else:
print "ERROR: subject contains not ascii characters, try again"
pressKey()
continue
if recipient == "":
recipient = raw_input("Insert recipient email address or newsgroup name: ")
>>>>>>> added command line option for testing nyms
if X_is_running():
text = easygui.textbox(msg='Write your message....', title='Input Box', text='', codebox=0)
if text == "":
if X_is_running():
text = easygui.textbox(msg='Write your message....', title='Input Box', text='', codebox=0)
else:
text = editMessage()
text = filter(lambda x: x in string.printable, text)
if isGpg(text):
print "message already encrypted"
pressKey()
elif gpgfuncts.encrypt("test", recipient, test=True).status == "encryption ok":
# really bad fix to solve a ridiculous problem, first line gets removed... to be investigated
text = "Message:\n" + text
text = gpgfuncts.encrypt(text, recipient)
print "message has been encrypted with %s public key" % recipient
pressKey()
else:
print "msg has not been encrypted, public key for %s not found" % recipient
pressKey()
else:
text = editMessage()
text = filter(lambda x: x in string.printable, text)
if isGpg(text):
print "message already encrypted"
pressKey()
elif gpgfuncts.encrypt("test", recipient, test=True).status == "encryption ok":
# really bad fix to solve a ridicoulus problem, first line get removed... to be investigated
text = "Message:\n" + text
text = gpgfuncts.encrypt(text, recipient)
print "message has been encrypted with %s public key" % recipient
pressKey()
else:
print "msg has not been encrypted, public key for %s not found" % recipient
pressKey()
msg = "From: %s\n" % anym.name
if validateEmail(recipient):
......@@ -297,13 +320,17 @@ def writeMessage():
emsg = signCryptMsg(msg, dest, sign=anym.fp, passphrase=pwd)
sendMixMsg(dest, emsg)
if test == 1:
sendMixMsg(dest, emsg, chain="paranoia")
else:
sendMixMsg(dest, emsg)
def modifyConfig():
pass
<<<<<<< HEAD
if checks.OptionsCheck(config) is True:
config['last_message'] = "OK, initial check passed"
......@@ -315,13 +342,20 @@ else:
def chooseChain():
=======
def chooseChain(chain=""):
>>>>>>> added command line option for testing nyms
""" Print remailer list and prompt for chain choice """
if chain != "":
config['remailer_chain'] = [chain]
return
print "\nChoose remailer chain used to send the message to the nymserver\n"
for remailer in uptime_sort_m():
print format_stats(remailer)
chain = raw_input('Choose remailer to be chained (by num), separated by commas, or write "r" for a random chain (3 remailers): ')
if chain == "r":
#chooseRandomChain()
config['remailer_chain'] = ['*','*','*']
return
else:
validateChain(chain)
......@@ -380,17 +414,41 @@ def checkBrokenChains(remailer_chain):
else:
return False
try:
parse_stats()
menu()
def main():
if checks.OptionsCheck(config) == True:
config['last_message'] = "OK, initial check passed"
except KeyboardInterrupt:
print "program terminated"
except SystemExit:
print "program terminated, bye"
except:
print bcolors.RED + "\nAn unhandled exception occured, here's the traceback!\n" + bcolors.ENDC
traceback.print_exc()
print bcolors.RED + "\nReport this to putro@autistici.org" + bcolors.ENDC
sys.exit()
if not nyms.sections:
print "No nyms configured, going to create it..."
createNym()
else:
setActiveNym(nyms.sections[0])
parser = optparse.OptionParser()
parser.add_option('--test', action='store_true', dest='test')
opts, args = parser.parse_args()
try:
if opts.test:
#setActiveNym(anym.name)
setActiveNym("1234@nymphet.paranoici.org")
parse_stats()
writeMessage(subject="prova", recipient="putro@autistici.org", text="asdadsfj", test=1)
else:
parse_stats()
menu()
except KeyboardInterrupt:
print "program terminated"
except SystemExit:
print "program terminated, bye"
except:
print bcolors.RED + "\nAn unhandled exception occured, here's the traceback!\n" + bcolors.ENDC
traceback.print_exc()
print bcolors.RED + "\nReport this to putro@autistici.org" + bcolors.ENDC
sys.exit()
if __name__ == '__main__':
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment