pySim-prog.py: add presence/length checks for user-provided SPN

Change-Id: I35fab9a85efda2b83f221a460d31c7d41db582b0
diff --git a/pySim/cards.py b/pySim/cards.py
index faaeca3..022182c 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -613,8 +613,9 @@
 			data, sw = self._scc.update_binary('00F7', content)
 
 		# set Service Provider Name
-		content = enc_spn(p['name'], True, True)
-		data, sw = self._scc.update_binary('6F46', rpad(content, 32))
+		if p.get('name') is not None:
+			content = enc_spn(p['name'], True, True)
+			data, sw = self._scc.update_binary('6F46', rpad(content, 32))
 
 		# write EF.IMSI
 		data, sw = self._scc.update_binary('6f07', enc_imsi(p['imsi']))