Snake case

main
Bob Mottram 2021-12-28 16:56:57 +00:00
parent c6cc551605
commit 4f62625a4b
13 changed files with 94 additions and 93 deletions

View File

@ -21,7 +21,7 @@ import pyqrcode
from hashlib import sha256 from hashlib import sha256
from hashlib import md5 from hashlib import md5
from shutil import copyfile from shutil import copyfile
from session import createSession from session import create_session
from webfinger import webfingerMeta from webfinger import webfingerMeta
from webfinger import webfingerNodeInfo from webfinger import webfingerNodeInfo
from webfinger import webfingerLookup from webfinger import webfingerLookup
@ -701,7 +701,7 @@ class PubServer(BaseHTTPRequestHandler):
if self.server.session: if self.server.session:
return True return True
print('DEBUG: creating new session during ' + callingFunction) print('DEBUG: creating new session during ' + callingFunction)
self.server.session = createSession(self.server.proxy_type) self.server.session = create_session(self.server.proxy_type)
if self.server.session: if self.server.session:
return True return True
print('ERROR: GET failed to create session during ' + print('ERROR: GET failed to create session during ' +
@ -17477,7 +17477,7 @@ class PubServer(BaseHTTPRequestHandler):
if not self._establishSession("POST"): if not self._establishSession("POST"):
fitnessPerformance(POSTstartTime, self.server.fitness, fitnessPerformance(POSTstartTime, self.server.fitness,
'_POST', 'createSession', '_POST', 'create_session',
self.server.debug) self.server.debug)
self._404() self._404()
return return

View File

@ -26,7 +26,7 @@ from utils import get_nickname_from_actor
from utils import get_domain_from_actor from utils import get_domain_from_actor
from utils import is_pgp_encrypted from utils import is_pgp_encrypted
from utils import local_actor_url from utils import local_actor_url
from session import createSession from session import create_session
from speaker import speakableText from speaker import speakableText
from speaker import getSpeakerPitch from speaker import getSpeakerPitch
from speaker import getSpeakerRate from speaker import getSpeakerRate
@ -1403,7 +1403,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
sayStr = indent + 'Connecting...' sayStr = indent + 'Connecting...'
_sayCommand(sayStr, sayStr, screenreader, _sayCommand(sayStr, sayStr, screenreader,
system_language, espeak) system_language, espeak)
session = createSession(proxy_type) session = create_session(proxy_type)
sayStr = indent + '/q or /quit to exit' sayStr = indent + '/q or /quit to exit'
_sayCommand(sayStr, sayStr, screenreader, _sayCommand(sayStr, sayStr, screenreader,
@ -1501,7 +1501,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
desktopShown = True desktopShown = True
prevTimelineFirstId = timelineFirstId prevTimelineFirstId = timelineFirstId
else: else:
session = createSession(proxy_type) session = create_session(proxy_type)
if not desktopShown: if not desktopShown:
if not session: if not session:
print('No session\n') print('No session\n')
@ -1728,7 +1728,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
if post_json_object['object'].get('conversation'): if post_json_object['object'].get('conversation'):
conversationId = \ conversationId = \
post_json_object['object']['conversation'] post_json_object['object']['conversation']
sessionReply = createSession(proxy_type) sessionReply = create_session(proxy_type)
_desktopReplyToPost(sessionReply, post_id, _desktopReplyToPost(sessionReply, post_id,
base_dir, nickname, password, base_dir, nickname, password,
domain, port, http_prefix, domain, port, http_prefix,
@ -1747,7 +1747,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
commandStr.startswith('direct message ') or commandStr.startswith('direct message ') or
commandStr.startswith('post ') or commandStr.startswith('post ') or
commandStr.startswith('send ')): commandStr.startswith('send ')):
sessionPost = createSession(proxy_type) sessionPost = create_session(proxy_type)
if commandStr.startswith('dm ') or \ if commandStr.startswith('dm ') or \
commandStr.startswith('direct message ') or \ commandStr.startswith('direct message ') or \
commandStr.startswith('post ') or \ commandStr.startswith('post ') or \
@ -1806,7 +1806,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
_sayCommand(sayStr, sayStr, _sayCommand(sayStr, sayStr,
screenreader, screenreader,
system_language, espeak) system_language, espeak)
sessionLike = createSession(proxy_type) sessionLike = create_session(proxy_type)
sendLikeViaServer(base_dir, sessionLike, sendLikeViaServer(base_dir, sessionLike,
nickname, password, nickname, password,
domain, port, http_prefix, domain, port, http_prefix,
@ -1845,7 +1845,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
_sayCommand(sayStr, sayStr, _sayCommand(sayStr, sayStr,
screenreader, screenreader,
system_language, espeak) system_language, espeak)
sessionMute = createSession(proxy_type) sessionMute = create_session(proxy_type)
sendUndoMuteViaServer(base_dir, sessionMute, sendUndoMuteViaServer(base_dir, sessionMute,
nickname, password, nickname, password,
domain, port, domain, port,
@ -1877,7 +1877,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
_sayCommand(sayStr, sayStr, _sayCommand(sayStr, sayStr,
screenreader, screenreader,
system_language, espeak) system_language, espeak)
sessionMute = createSession(proxy_type) sessionMute = create_session(proxy_type)
sendMuteViaServer(base_dir, sessionMute, sendMuteViaServer(base_dir, sessionMute,
nickname, password, nickname, password,
domain, port, domain, port,
@ -1918,7 +1918,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
_sayCommand(sayStr, sayStr, _sayCommand(sayStr, sayStr,
screenreader, screenreader,
system_language, espeak) system_language, espeak)
sessionbm = createSession(proxy_type) sessionbm = create_session(proxy_type)
sendUndoBookmarkViaServer(base_dir, sessionbm, sendUndoBookmarkViaServer(base_dir, sessionbm,
nickname, password, nickname, password,
domain, port, http_prefix, domain, port, http_prefix,
@ -1949,7 +1949,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
_sayCommand(sayStr, sayStr, _sayCommand(sayStr, sayStr,
screenreader, screenreader,
system_language, espeak) system_language, espeak)
sessionbm = createSession(proxy_type) sessionbm = create_session(proxy_type)
sendBookmarkViaServer(base_dir, sessionbm, sendBookmarkViaServer(base_dir, sessionbm,
nickname, password, nickname, password,
domain, port, http_prefix, domain, port, http_prefix,
@ -1983,7 +1983,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
_sayCommand(sayStr, sayStr, _sayCommand(sayStr, sayStr,
screenreader, screenreader,
system_language, espeak) system_language, espeak)
sessionBlock = createSession(proxy_type) sessionBlock = create_session(proxy_type)
sendUndoBlockViaServer(base_dir, sessionBlock, sendUndoBlockViaServer(base_dir, sessionBlock,
nickname, password, nickname, password,
domain, port, domain, port,
@ -2030,7 +2030,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
_sayCommand(sayStr, sayStr, _sayCommand(sayStr, sayStr,
screenreader, screenreader,
system_language, espeak) system_language, espeak)
sessionBlock = createSession(proxy_type) sessionBlock = create_session(proxy_type)
sendBlockViaServer(base_dir, sessionBlock, sendBlockViaServer(base_dir, sessionBlock,
nickname, password, nickname, password,
domain, port, domain, port,
@ -2061,7 +2061,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
_sayCommand(sayStr, sayStr, _sayCommand(sayStr, sayStr,
screenreader, screenreader,
system_language, espeak) system_language, espeak)
sessionUnlike = createSession(proxy_type) sessionUnlike = create_session(proxy_type)
sendUndoLikeViaServer(base_dir, sessionUnlike, sendUndoLikeViaServer(base_dir, sessionUnlike,
nickname, password, nickname, password,
domain, port, http_prefix, domain, port, http_prefix,
@ -2092,7 +2092,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
_sayCommand(sayStr, sayStr, _sayCommand(sayStr, sayStr,
screenreader, screenreader,
system_language, espeak) system_language, espeak)
sessionAnnounce = createSession(proxy_type) sessionAnnounce = create_session(proxy_type)
sendAnnounceViaServer(base_dir, sessionAnnounce, sendAnnounceViaServer(base_dir, sessionAnnounce,
nickname, password, nickname, password,
domain, port, domain, port,
@ -2125,7 +2125,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
_sayCommand(sayStr, sayStr, _sayCommand(sayStr, sayStr,
screenreader, screenreader,
system_language, espeak) system_language, espeak)
sessionAnnounce = createSession(proxy_type) sessionAnnounce = create_session(proxy_type)
sendUndoAnnounceViaServer(base_dir, sessionAnnounce, sendUndoAnnounceViaServer(base_dir, sessionAnnounce,
post_json_object, post_json_object,
nickname, password, nickname, password,
@ -2220,7 +2220,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
followNickname + '@' + followDomain followNickname + '@' + followDomain
_sayCommand(sayStr, sayStr, _sayCommand(sayStr, sayStr,
screenreader, system_language, espeak) screenreader, system_language, espeak)
sessionFollow = createSession(proxy_type) sessionFollow = create_session(proxy_type)
sendFollowRequestViaServer(base_dir, sendFollowRequestViaServer(base_dir,
sessionFollow, sessionFollow,
nickname, password, nickname, password,
@ -2256,7 +2256,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
followNickname + '@' + followDomain followNickname + '@' + followDomain
_sayCommand(sayStr, sayStr, _sayCommand(sayStr, sayStr,
screenreader, system_language, espeak) screenreader, system_language, espeak)
sessionUnfollow = createSession(proxy_type) sessionUnfollow = create_session(proxy_type)
sendUnfollowRequestViaServer(base_dir, sessionUnfollow, sendUnfollowRequestViaServer(base_dir, sessionUnfollow,
nickname, password, nickname, password,
domain, port, domain, port,
@ -2287,7 +2287,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
approveNickname + '@' + approveDomain approveNickname + '@' + approveDomain
_sayCommand(sayStr, sayStr, _sayCommand(sayStr, sayStr,
screenreader, system_language, espeak) screenreader, system_language, espeak)
sessionApprove = createSession(proxy_type) sessionApprove = create_session(proxy_type)
approveFollowRequestViaServer(base_dir, sessionApprove, approveFollowRequestViaServer(base_dir, sessionApprove,
nickname, password, nickname, password,
domain, port, domain, port,
@ -2320,7 +2320,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
denyNickname + '@' + denyDomain denyNickname + '@' + denyDomain
_sayCommand(sayStr, sayStr, _sayCommand(sayStr, sayStr,
screenreader, system_language, espeak) screenreader, system_language, espeak)
sessionDeny = createSession(proxy_type) sessionDeny = create_session(proxy_type)
denyFollowRequestViaServer(base_dir, sessionDeny, denyFollowRequestViaServer(base_dir, sessionDeny,
nickname, password, nickname, password,
domain, port, domain, port,
@ -2495,7 +2495,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
_sayCommand(sayStr, sayStr, _sayCommand(sayStr, sayStr,
screenreader, screenreader,
system_language, espeak) system_language, espeak)
sessionrm = createSession(proxy_type) sessionrm = create_session(proxy_type)
sendDeleteViaServer(base_dir, sessionrm, sendDeleteViaServer(base_dir, sessionrm,
nickname, password, nickname, password,
domain, port, domain, port,

View File

@ -41,7 +41,7 @@ from posts import sendPostViaServer
from posts import getPublicPostsOfPerson from posts import getPublicPostsOfPerson
from posts import getUserUrl from posts import getUserUrl
from posts import checkDomains from posts import checkDomains
from session import createSession from session import create_session
from session import getJson from session import getJson
from session import downloadHtml from session import downloadHtml
from newswire import getRSS from newswire import getRSS
@ -934,7 +934,7 @@ if args.postsraw:
sys.exit() sys.exit()
if args.json: if args.json:
session = createSession(None) session = create_session(None)
profileStr = 'https://www.w3.org/ns/activitystreams' profileStr = 'https://www.w3.org/ns/activitystreams'
asHeader = { asHeader = {
'Accept': 'application/ld+json; profile="' + profileStr + '"' 'Accept': 'application/ld+json; profile="' + profileStr + '"'
@ -958,7 +958,7 @@ if args.json:
sys.exit() sys.exit()
if args.htmlpost: if args.htmlpost:
session = createSession(None) session = create_session(None)
profileStr = 'https://www.w3.org/ns/activitystreams' profileStr = 'https://www.w3.org/ns/activitystreams'
asHeader = { asHeader = {
'Accept': 'text/html; profile="' + profileStr + '"' 'Accept': 'text/html; profile="' + profileStr + '"'
@ -1044,7 +1044,7 @@ if args.domain:
set_config_param(base_dir, 'domain', domain) set_config_param(base_dir, 'domain', domain)
if args.rss: if args.rss:
session = createSession(None) session = create_session(None)
testRSS = getRSS(base_dir, domain, session, args.rss, testRSS = getRSS(base_dir, domain, session, args.rss,
False, False, 1000, 1000, 1000, 1000, debug) False, False, 1000, 1000, 1000, 1000, debug)
pprint(testRSS) pprint(testRSS)
@ -1182,7 +1182,7 @@ if args.approve:
if '@' not in args.approve: if '@' not in args.approve:
print('syntax: --approve nick@domain') print('syntax: --approve nick@domain')
sys.exit() sys.exit()
session = createSession(proxy_type) session = create_session(proxy_type)
send_threads = [] send_threads = []
postLog = [] postLog = []
cached_webfingers = {} cached_webfingers = {}
@ -1210,7 +1210,7 @@ if args.deny:
if '@' not in args.deny: if '@' not in args.deny:
print('syntax: --deny nick@domain') print('syntax: --deny nick@domain')
sys.exit() sys.exit()
session = createSession(proxy_type) session = create_session(proxy_type)
send_threads = [] send_threads = []
postLog = [] postLog = []
cached_webfingers = {} cached_webfingers = {}
@ -1261,7 +1261,7 @@ if args.message:
sys.exit() sys.exit()
args.password = args.password.replace('\n', '') args.password = args.password.replace('\n', '')
session = createSession(proxy_type) session = create_session(proxy_type)
if not args.sendto: if not args.sendto:
print('Specify an account to sent to: --sendto [nickname@domain]') print('Specify an account to sent to: --sendto [nickname@domain]')
sys.exit() sys.exit()
@ -1343,7 +1343,7 @@ if args.announce:
sys.exit() sys.exit()
args.password = args.password.replace('\n', '') args.password = args.password.replace('\n', '')
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
if not domain: if not domain:
@ -1396,7 +1396,7 @@ if args.box:
if args.secure_mode: if args.secure_mode:
signing_priv_key_pem = getInstanceActorKey(base_dir, domain) signing_priv_key_pem = getInstanceActorKey(base_dir, domain)
session = createSession(proxy_type) session = create_session(proxy_type)
boxJson = c2sBoxJson(base_dir, session, boxJson = c2sBoxJson(base_dir, session,
args.nickname, args.password, args.nickname, args.password,
domain, port, http_prefix, domain, port, http_prefix,
@ -1448,7 +1448,7 @@ if args.itemName:
'with the --duration option') 'with the --duration option')
sys.exit() sys.exit()
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
if not domain: if not domain:
@ -1491,7 +1491,7 @@ if args.undoItemName:
print('Specify a nickname with the --nickname option') print('Specify a nickname with the --nickname option')
sys.exit() sys.exit()
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
if not domain: if not domain:
@ -1553,7 +1553,7 @@ if args.wantedItemName:
'with the --duration option') 'with the --duration option')
sys.exit() sys.exit()
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
if not domain: if not domain:
@ -1596,7 +1596,7 @@ if args.undoWantedItemName:
print('Specify a nickname with the --nickname option') print('Specify a nickname with the --nickname option')
sys.exit() sys.exit()
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
if not domain: if not domain:
@ -1630,7 +1630,7 @@ if args.like:
sys.exit() sys.exit()
args.password = args.password.replace('\n', '') args.password = args.password.replace('\n', '')
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
if not domain: if not domain:
@ -1669,7 +1669,7 @@ if args.react:
sys.exit() sys.exit()
args.password = args.password.replace('\n', '') args.password = args.password.replace('\n', '')
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
if not domain: if not domain:
@ -1702,7 +1702,7 @@ if args.undolike:
sys.exit() sys.exit()
args.password = args.password.replace('\n', '') args.password = args.password.replace('\n', '')
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
if not domain: if not domain:
@ -1742,7 +1742,7 @@ if args.undoreact:
sys.exit() sys.exit()
args.password = args.password.replace('\n', '') args.password = args.password.replace('\n', '')
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
if not domain: if not domain:
@ -1776,7 +1776,7 @@ if args.bookmark:
sys.exit() sys.exit()
args.password = args.password.replace('\n', '') args.password = args.password.replace('\n', '')
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
if not domain: if not domain:
@ -1810,7 +1810,7 @@ if args.unbookmark:
sys.exit() sys.exit()
args.password = args.password.replace('\n', '') args.password = args.password.replace('\n', '')
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
if not domain: if not domain:
@ -1843,7 +1843,7 @@ if args.delete:
sys.exit() sys.exit()
args.password = args.password.replace('\n', '') args.password = args.password.replace('\n', '')
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
if not domain: if not domain:
@ -1885,7 +1885,7 @@ if args.follow:
sys.exit() sys.exit()
followDomain, followPort = get_domain_from_actor(args.follow) followDomain, followPort = get_domain_from_actor(args.follow)
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
followHttpPrefix = http_prefix followHttpPrefix = http_prefix
@ -1931,7 +1931,7 @@ if args.unfollow:
sys.exit() sys.exit()
followDomain, followPort = get_domain_from_actor(args.unfollow) followDomain, followPort = get_domain_from_actor(args.unfollow)
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
followHttpPrefix = http_prefix followHttpPrefix = http_prefix
@ -1968,7 +1968,7 @@ if args.followingList:
sys.exit() sys.exit()
args.password = args.password.replace('\n', '') args.password = args.password.replace('\n', '')
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
followHttpPrefix = http_prefix followHttpPrefix = http_prefix
@ -2001,7 +2001,7 @@ if args.followersList:
sys.exit() sys.exit()
args.password = args.password.replace('\n', '') args.password = args.password.replace('\n', '')
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
followHttpPrefix = http_prefix followHttpPrefix = http_prefix
@ -2035,7 +2035,7 @@ if args.followRequestsList:
sys.exit() sys.exit()
args.password = args.password.replace('\n', '') args.password = args.password.replace('\n', '')
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
followHttpPrefix = http_prefix followHttpPrefix = http_prefix
@ -2090,7 +2090,7 @@ if args.migrations:
else: else:
http_prefix = 'https' http_prefix = 'https'
port = 443 port = 443
session = createSession(proxy_type) session = create_session(proxy_type)
if not domain: if not domain:
domain = get_config_param(base_dir, 'domain') domain = get_config_param(base_dir, 'domain')
signing_priv_key_pem = None signing_priv_key_pem = None
@ -2187,7 +2187,7 @@ if args.followers:
else: else:
http_prefix = 'https' http_prefix = 'https'
port = 443 port = 443
session = createSession(proxy_type) session = create_session(proxy_type)
if nickname == 'inbox': if nickname == 'inbox':
nickname = domain nickname = domain
@ -2496,7 +2496,7 @@ if args.skill:
print('Skill level should be a percentage in the range 0-100') print('Skill level should be a percentage in the range 0-100')
sys.exit() sys.exit()
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
if not domain: if not domain:
@ -2531,7 +2531,7 @@ if args.availability:
sys.exit() sys.exit()
args.password = args.password.replace('\n', '') args.password = args.password.replace('\n', '')
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
if not domain: if not domain:
@ -2645,7 +2645,7 @@ if args.block:
print(args.block + ' does not look like an actor url') print(args.block + ' does not look like an actor url')
sys.exit() sys.exit()
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
if not domain: if not domain:
@ -2677,7 +2677,7 @@ if args.mute:
sys.exit() sys.exit()
args.password = args.password.replace('\n', '') args.password = args.password.replace('\n', '')
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
if not domain: if not domain:
@ -2709,7 +2709,7 @@ if args.unmute:
sys.exit() sys.exit()
args.password = args.password.replace('\n', '') args.password = args.password.replace('\n', '')
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
if not domain: if not domain:
@ -2753,7 +2753,7 @@ if args.unblock:
print(args.unblock + ' does not look like an actor url') print(args.unblock + ' does not look like an actor url')
sys.exit() sys.exit()
session = createSession(proxy_type) session = create_session(proxy_type)
person_cache = {} person_cache = {}
cached_webfingers = {} cached_webfingers = {}
if not domain: if not domain:

View File

@ -65,7 +65,7 @@ from categories import getHashtagCategories
from categories import setHashtagCategory from categories import setHashtagCategory
from httpsig import getDigestAlgorithmFromHeaders from httpsig import getDigestAlgorithmFromHeaders
from httpsig import verifyPostHeaders from httpsig import verifyPostHeaders
from session import createSession from session import create_session
from follow import followerApprovalActive from follow import followerApprovalActive
from follow import isFollowingActor from follow import isFollowingActor
from follow import getFollowersOfActor from follow import getFollowersOfActor
@ -4106,7 +4106,7 @@ def runInboxQueue(recent_posts_cache: {}, max_recent_posts: int,
currSessionTime = int(time.time()) currSessionTime = int(time.time())
session_last_update = currSessionTime session_last_update = currSessionTime
print('Starting new session when starting inbox queue') print('Starting new session when starting inbox queue')
session = createSession(proxy_type) session = create_session(proxy_type)
inboxHandle = 'inbox@' + domain inboxHandle = 'inbox@' + domain
if debug: if debug:
print('DEBUG: Inbox queue running') print('DEBUG: Inbox queue running')
@ -4164,7 +4164,7 @@ def runInboxQueue(recent_posts_cache: {}, max_recent_posts: int,
# recreate the session periodically # recreate the session periodically
if not session or curr_time - session_last_update > 21600: if not session or curr_time - session_last_update > 21600:
print('Regenerating inbox queue session at 6hr interval') print('Regenerating inbox queue session at 6hr interval')
session = createSession(proxy_type) session = create_session(proxy_type)
if not session: if not session:
continue continue
session_last_update = curr_time session_last_update = curr_time

View File

@ -35,7 +35,7 @@ from utils import clear_from_post_caches
from utils import dangerous_markup from utils import dangerous_markup
from utils import local_actor_url from utils import local_actor_url
from inbox import storeHashTags from inbox import storeHashTags
from session import createSession from session import create_session
def _updateFeedsOutboxIndex(base_dir: str, domain: str, post_id: str) -> None: def _updateFeedsOutboxIndex(base_dir: str, domain: str, post_id: str) -> None:
@ -785,7 +785,7 @@ def runNewswireDaemon(base_dir: str, httpd,
# has the session been created yet? # has the session been created yet?
if not httpd.session: if not httpd.session:
print('Newswire daemon waiting for session') print('Newswire daemon waiting for session')
httpd.session = createSession(httpd.proxy_type) httpd.session = create_session(httpd.proxy_type)
if not httpd.session: if not httpd.session:
print('Newswire daemon has no session') print('Newswire daemon has no session')
time.sleep(60) time.sleep(60)

View File

@ -9,7 +9,7 @@ __module_group__ = "Timeline"
import os import os
from shutil import copyfile from shutil import copyfile
from session import createSession from session import create_session
from auth import createPassword from auth import createPassword
from posts import isImageMedia from posts import isImageMedia
from posts import outboxMessageCreateWrap from posts import outboxMessageCreateWrap
@ -485,7 +485,7 @@ def postMessageToOutbox(session, translate: {},
'for the post associated with the Announce activity') 'for the post associated with the Announce activity')
if not server.session: if not server.session:
print('DEBUG: creating new session for c2s') print('DEBUG: creating new session for c2s')
server.session = createSession(proxy_type) server.session = create_session(proxy_type)
if not server.session: if not server.session:
print('ERROR: Failed to create session for postMessageToOutbox') print('ERROR: Failed to create session for postMessageToOutbox')
return False return False

View File

@ -60,7 +60,7 @@ from utils import get_user_paths
from utils import get_group_paths from utils import get_group_paths
from utils import local_actor_url from utils import local_actor_url
from utils import dangerous_svg from utils import dangerous_svg
from session import createSession from session import create_session
from session import getJson from session import getJson
from webfinger import webfingerHandle from webfinger import webfingerHandle
from pprint import pprint from pprint import pprint
@ -1518,7 +1518,7 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
if existingSession: if existingSession:
session = existingSession session = existingSession
else: else:
session = createSession(proxy_type) session = create_session(proxy_type)
if nickname == 'inbox': if nickname == 'inbox':
nickname = domain nickname = domain

View File

@ -23,7 +23,7 @@ from cache import storePersonInCache
from cache import getPersonFromCache from cache import getPersonFromCache
from cache import expirePersonCache from cache import expirePersonCache
from pprint import pprint from pprint import pprint
from session import createSession from session import create_session
from session import getJson from session import getJson
from session import postJson from session import postJson
from session import postJsonString from session import postJsonString
@ -4077,7 +4077,7 @@ def getPublicPostsOfPerson(base_dir: str, nickname: str, domain: str,
print('Signing key missing') print('Signing key missing')
print('Starting new session for getting public posts') print('Starting new session for getting public posts')
session = createSession(proxy_type) session = create_session(proxy_type)
if not session: if not session:
if debug: if debug:
print('Session was not created') print('Session was not created')
@ -4140,7 +4140,7 @@ def getPublicPostDomains(session, base_dir: str, nickname: str, domain: str,
""" Returns a list of domains referenced within public posts """ Returns a list of domains referenced within public posts
""" """
if not session: if not session:
session = createSession(proxy_type) session = create_session(proxy_type)
if not session: if not session:
return domainList return domainList
person_cache = {} person_cache = {}
@ -4236,7 +4236,7 @@ def getPublicPostInfo(session, base_dir: str, nickname: str, domain: str,
""" Returns a dict of domains referenced within public posts """ Returns a dict of domains referenced within public posts
""" """
if not session: if not session:
session = createSession(proxy_type) session = create_session(proxy_type)
if not session: if not session:
return {} return {}
person_cache = {} person_cache = {}

View File

@ -20,21 +20,22 @@ from http.client import HTTPConnection
base_directory = None base_directory = None
def createSession(proxy_type: str): def create_session(proxy_type: str):
session = None session = None
try: try:
session = requests.session() session = requests.session()
except requests.exceptions.RequestException as ex: except requests.exceptions.RequestException as ex:
print('WARN: requests error during createSession ' + str(ex)) print('WARN: requests error during create_session ' + str(ex))
return None return None
except SocketError as ex: except SocketError as ex:
if ex.errno == errno.ECONNRESET: if ex.errno == errno.ECONNRESET:
print('WARN: connection was reset during createSession ' + str(ex)) print('WARN: connection was reset during create_session ' +
str(ex))
else: else:
print('WARN: socket error during createSession ' + str(ex)) print('WARN: socket error during create_session ' + str(ex))
return None return None
except ValueError as ex: except ValueError as ex:
print('WARN: error during createSession ' + str(ex)) print('WARN: error during create_session ' + str(ex))
return None return None
if not session: if not session:
return None return None

View File

@ -21,7 +21,7 @@ from auth import constantTimeStringCheck
from posts import getPersonBox from posts import getPersonBox
from session import postJson from session import postJson
from session import postImage from session import postImage
from session import createSession from session import create_session
from utils import has_object_stringType from utils import has_object_stringType
from utils import date_string_to_seconds from utils import date_string_to_seconds
from utils import date_seconds_to_string from utils import date_seconds_to_string
@ -1741,7 +1741,7 @@ def runFederatedSharesDaemon(base_dir: str, httpd, http_prefix: str,
time.sleep(fileCheckIntervalSec) time.sleep(fileCheckIntervalSec)
continue continue
session = createSession(proxy_type) session = create_session(proxy_type)
for sharesFileType in get_shares_files_list(): for sharesFileType in get_shares_files_list():
_updateFederatedSharesCache(session, _updateFederatedSharesCache(session,
shared_items_federated_domains, shared_items_federated_domains,

View File

@ -7,7 +7,7 @@ __email__ = "bob@libreserver.org"
__status__ = "Production" __status__ = "Production"
__module_group__ = "Moderation" __module_group__ = "Moderation"
from session import createSession from session import create_session
from webfinger import webfingerHandle from webfinger import webfingerHandle
from posts import getPersonBox from posts import getPersonBox
from posts import getPostDomains from posts import getPostDomains
@ -27,7 +27,7 @@ def instancesGraph(base_dir: str, handles: str,
dotGraphStr = 'digraph instances {\n' dotGraphStr = 'digraph instances {\n'
if ',' not in handles: if ',' not in handles:
return dotGraphStr + '}\n' return dotGraphStr + '}\n'
session = createSession(proxy_type) session = create_session(proxy_type)
if not session: if not session:
return dotGraphStr + '}\n' return dotGraphStr + '}\n'

View File

@ -34,7 +34,7 @@ from cache import storePersonInCache
from cache import getPersonFromCache from cache import getPersonFromCache
from threads import threadWithTrace from threads import threadWithTrace
from daemon import runDaemon from daemon import runDaemon
from session import createSession from session import create_session
from session import getJson from session import getJson
from posts import getActorFromInReplyTo from posts import getActorFromInReplyTo
from posts import regenerateIndexForBox from posts import regenerateIndexForBox
@ -1179,7 +1179,7 @@ def testPostMessageBetweenServers(base_dir: str) -> None:
print('\n\n*******************************************************') print('\n\n*******************************************************')
print('Alice sends to Bob') print('Alice sends to Bob')
os.chdir(aliceDir) os.chdir(aliceDir)
sessionAlice = createSession(proxy_type) sessionAlice = create_session(proxy_type)
inReplyTo = None inReplyTo = None
inReplyToAtomUri = None inReplyToAtomUri = None
subject = None subject = None
@ -1313,7 +1313,7 @@ def testPostMessageBetweenServers(base_dir: str) -> None:
follow_person(aliceDir, 'alice', aliceDomain, 'bob', follow_person(aliceDir, 'alice', aliceDomain, 'bob',
bobDomainStr, federation_list, False, False) bobDomainStr, federation_list, False, False)
sessionBob = createSession(proxy_type) sessionBob = create_session(proxy_type)
bobPostLog = [] bobPostLog = []
bobPersonCache = {} bobPersonCache = {}
bobCachedWebfingers = {} bobCachedWebfingers = {}
@ -1511,7 +1511,7 @@ def testFollowBetweenServers(base_dir: str) -> None:
print('*********************************************************') print('*********************************************************')
print('Alice sends a follow request to Bob') print('Alice sends a follow request to Bob')
os.chdir(aliceDir) os.chdir(aliceDir)
sessionAlice = createSession(proxy_type) sessionAlice = create_session(proxy_type)
inReplyTo = None inReplyTo = None
inReplyToAtomUri = None inReplyToAtomUri = None
subject = None subject = None
@ -1699,7 +1699,7 @@ def testSharedItemsFederation(base_dir: str) -> None:
time.sleep(1) time.sleep(1)
signing_priv_key_pem = None signing_priv_key_pem = None
sessionClient = createSession(proxy_type) sessionClient = create_session(proxy_type)
# Get Bob's instance actor # Get Bob's instance actor
print('\n\n*********************************************************') print('\n\n*********************************************************')
@ -1729,7 +1729,7 @@ def testSharedItemsFederation(base_dir: str) -> None:
print('*********************************************************') print('*********************************************************')
print('Alice sends a follow request to Bob') print('Alice sends a follow request to Bob')
os.chdir(aliceDir) os.chdir(aliceDir)
sessionAlice = createSession(proxy_type) sessionAlice = create_session(proxy_type)
inReplyTo = None inReplyTo = None
inReplyToAtomUri = None inReplyToAtomUri = None
subject = None subject = None
@ -1809,7 +1809,7 @@ def testSharedItemsFederation(base_dir: str) -> None:
sharedItemPrice = "1.30" sharedItemPrice = "1.30"
sharedItemCurrency = "EUR" sharedItemCurrency = "EUR"
signing_priv_key_pem = None signing_priv_key_pem = None
sessionBob = createSession(proxy_type) sessionBob = create_session(proxy_type)
shareJson = \ shareJson = \
sendShareViaServer(bobDir, sessionBob, sendShareViaServer(bobDir, sessionBob,
'bob', bobPassword, 'bob', bobPassword,
@ -2130,7 +2130,7 @@ def testGroupFollow(base_dir: str) -> None:
print('*********************************************************') print('*********************************************************')
print('Alice has some outbox posts') print('Alice has some outbox posts')
aliceOutbox = 'http://' + aliceAddress + '/users/alice/outbox' aliceOutbox = 'http://' + aliceAddress + '/users/alice/outbox'
session = createSession(None) session = create_session(None)
profileStr = 'https://www.w3.org/ns/activitystreams' profileStr = 'https://www.w3.org/ns/activitystreams'
asHeader = { asHeader = {
'Accept': 'application/ld+json; profile="' + profileStr + '"' 'Accept': 'application/ld+json; profile="' + profileStr + '"'
@ -2165,7 +2165,7 @@ def testGroupFollow(base_dir: str) -> None:
print('*********************************************************') print('*********************************************************')
print('Alice sends a follow request to the test group') print('Alice sends a follow request to the test group')
os.chdir(aliceDir) os.chdir(aliceDir)
sessionAlice = createSession(proxy_type) sessionAlice = create_session(proxy_type)
inReplyTo = None inReplyTo = None
inReplyToAtomUri = None inReplyToAtomUri = None
subject = None subject = None
@ -2242,7 +2242,7 @@ def testGroupFollow(base_dir: str) -> None:
print('*********************************************************') print('*********************************************************')
print('Bob sends a follow request to the test group') print('Bob sends a follow request to the test group')
os.chdir(bobDir) os.chdir(bobDir)
sessionBob = createSession(proxy_type) sessionBob = create_session(proxy_type)
inReplyTo = None inReplyTo = None
inReplyToAtomUri = None inReplyToAtomUri = None
subject = None subject = None
@ -2856,7 +2856,7 @@ def testClientToServer(base_dir: str):
print('\n\n*******************************************************') print('\n\n*******************************************************')
print('EVENT: Alice sends to Bob via c2s') print('EVENT: Alice sends to Bob via c2s')
sessionAlice = createSession(proxy_type) sessionAlice = create_session(proxy_type)
followersOnly = False followersOnly = False
attachedImageFilename = base_dir + '/img/logo.png' attachedImageFilename = base_dir + '/img/logo.png'
mediaType = getAttachmentMediaType(attachedImageFilename) mediaType = getAttachmentMediaType(attachedImageFilename)
@ -3036,7 +3036,7 @@ def testClientToServer(base_dir: str):
assert 'alice@' + aliceDomain + ':' + str(alicePort) in \ assert 'alice@' + aliceDomain + ':' + str(alicePort) in \
open(bobDir + '/accounts/bob@' + bobDomain + '/following.txt').read() open(bobDir + '/accounts/bob@' + bobDomain + '/following.txt').read()
sessionBob = createSession(proxy_type) sessionBob = create_session(proxy_type)
password = 'bobpass' password = 'bobpass'
outboxPath = bobDir + '/accounts/bob@' + bobDomain + '/outbox' outboxPath = bobDir + '/accounts/bob@' + bobDomain + '/outbox'
inboxPath = aliceDir + '/accounts/alice@' + aliceDomain + '/inbox' inboxPath = aliceDir + '/accounts/alice@' + aliceDomain + '/inbox'
@ -5112,7 +5112,7 @@ def testUpdateActor(base_dir: str):
print('\n\n*******************************************************') print('\n\n*******************************************************')
print('Alice updates her PGP key') print('Alice updates her PGP key')
sessionAlice = createSession(proxy_type) sessionAlice = create_session(proxy_type)
cached_webfingers = {} cached_webfingers = {}
person_cache = {} person_cache = {}
password = 'alicepass' password = 'alicepass'

View File

@ -27,7 +27,7 @@ from webapp_utils import htmlHeaderWithExternalStyle
from webapp_utils import htmlFooter from webapp_utils import htmlFooter
from blocking import isBlockedDomain from blocking import isBlockedDomain
from blocking import isBlocked from blocking import isBlocked
from session import createSession from session import create_session
def htmlModeration(css_cache: {}, defaultTimeline: str, def htmlModeration(css_cache: {}, defaultTimeline: str,
@ -122,7 +122,7 @@ def htmlAccountInfo(css_cache: {}, translate: {},
if domain.endswith('.i2p'): if domain.endswith('.i2p'):
proxy_type = None proxy_type = None
session = createSession(proxy_type) session = create_session(proxy_type)
wordFrequency = {} wordFrequency = {}
originDomain = None originDomain = None