Browse Source

Less verbose when not in debug

merge-requests/21/head
Bob Mottram 2 months ago
parent
commit
faadca51b6
18 changed files with 71 additions and 54 deletions
  1. 1
    1
      announce.py
  2. 1
    1
      availability.py
  3. 12
    4
      daemon.py
  4. 1
    1
      delete.py
  5. 1
    1
      epicyon.py
  6. 2
    2
      follow.py
  7. 7
    6
      inbox.py
  8. 2
    2
      like.py
  9. 1
    1
      migrate.py
  10. 3
    2
      person.py
  11. 14
    13
      posts.py
  12. 1
    1
      roles.py
  13. 2
    2
      shares.py
  14. 1
    1
      skills.py
  15. 1
    1
      socnet.py
  16. 1
    1
      webapp_post.py
  17. 8
    6
      webapp_profile.py
  18. 12
    8
      webfinger.py

+ 1
- 1
announce.py View File

@@ -219,7 +219,7 @@ def sendAnnounceViaServer(baseDir: str, session,
219 219
     # lookup the inbox for the To handle
220 220
     wfRequest = webfingerHandle(session, handle, httpPrefix,
221 221
                                 cachedWebfingers,
222
-                                fromDomain, projectVersion)
222
+                                fromDomain, projectVersion, debug)
223 223
     if not wfRequest:
224 224
         if debug:
225 225
             print('DEBUG: announce webfinger failed for ' + handle)

+ 1
- 1
availability.py View File

@@ -105,7 +105,7 @@ def sendAvailabilityViaServer(baseDir: str, session,
105 105
     # lookup the inbox for the To handle
106 106
     wfRequest = webfingerHandle(session, handle, httpPrefix,
107 107
                                 cachedWebfingers,
108
-                                domain, projectVersion)
108
+                                domain, projectVersion, debug)
109 109
     if not wfRequest:
110 110
         if debug:
111 111
             print('DEBUG: announce webfinger failed for ' + handle)

+ 12
- 4
daemon.py View File

@@ -1379,7 +1379,7 @@ class PubServer(BaseHTTPRequestHandler):
1379 1379
             if GETtimings.get(prevGetId):
1380 1380
                 timeDiff = int(timeDiff - int(GETtimings[prevGetId]))
1381 1381
         GETtimings[currGetId] = str(timeDiff)
1382
-        if logEvent:
1382
+        if logEvent and self.server.debug:
1383 1383
             print('GET TIMING ' + currGetId + ' = ' + str(timeDiff))
1384 1384
 
1385 1385
     def _benchmarkPOSTtimings(self, POSTstartTime, POSTtimings: [],
@@ -1397,7 +1397,8 @@ class PubServer(BaseHTTPRequestHandler):
1397 1397
             if logEvent:
1398 1398
                 ctr = 1
1399 1399
                 for timeDiff in POSTtimings:
1400
-                    print('POST TIMING|' + str(ctr) + '|' + timeDiff)
1400
+                    if self.server.debug:
1401
+                        print('POST TIMING|' + str(ctr) + '|' + timeDiff)
1401 1402
                     ctr += 1
1402 1403
 
1403 1404
     def _pathContainsBlogLink(self, baseDir: str,
@@ -7351,6 +7352,7 @@ class PubServer(BaseHTTPRequestHandler):
7351 7352
                                     self.server.peertubeInstances,
7352 7353
                                     self.server.allowLocalNetworkAccess,
7353 7354
                                     self.server.textModeBanner,
7355
+                                    self.server.debug,
7354 7356
                                     actorJson['roles'],
7355 7357
                                     None, None)
7356 7358
                     msg = msg.encode('utf-8')
@@ -7439,6 +7441,7 @@ class PubServer(BaseHTTPRequestHandler):
7439 7441
                                                 self.server.peertubeInstances,
7440 7442
                                                 allowLocalNetworkAccess,
7441 7443
                                                 self.server.textModeBanner,
7444
+                                                self.server.debug,
7442 7445
                                                 actorJson['skills'],
7443 7446
                                                 None, None)
7444 7447
                                 msg = msg.encode('utf-8')
@@ -9243,6 +9246,7 @@ class PubServer(BaseHTTPRequestHandler):
9243 9246
                                     self.server.peertubeInstances,
9244 9247
                                     self.server.allowLocalNetworkAccess,
9245 9248
                                     self.server.textModeBanner,
9249
+                                    self.server.debug,
9246 9250
                                     shares,
9247 9251
                                     pageNumber, sharesPerPage)
9248 9252
                     msg = msg.encode('utf-8')
@@ -9341,6 +9345,7 @@ class PubServer(BaseHTTPRequestHandler):
9341 9345
                                     self.server.peertubeInstances,
9342 9346
                                     self.server.allowLocalNetworkAccess,
9343 9347
                                     self.server.textModeBanner,
9348
+                                    self.server.debug,
9344 9349
                                     following,
9345 9350
                                     pageNumber,
9346 9351
                                     followsPerPage).encode('utf-8')
@@ -9439,6 +9444,7 @@ class PubServer(BaseHTTPRequestHandler):
9439 9444
                                     self.server.peertubeInstances,
9440 9445
                                     self.server.allowLocalNetworkAccess,
9441 9446
                                     self.server.textModeBanner,
9447
+                                    self.server.debug,
9442 9448
                                     followers,
9443 9449
                                     pageNumber,
9444 9450
                                     followsPerPage).encode('utf-8')
@@ -9560,6 +9566,7 @@ class PubServer(BaseHTTPRequestHandler):
9560 9566
                             self.server.peertubeInstances,
9561 9567
                             self.server.allowLocalNetworkAccess,
9562 9568
                             self.server.textModeBanner,
9569
+                            self.server.debug,
9563 9570
                             None, None).encode('utf-8')
9564 9571
             msglen = len(msg)
9565 9572
             self._set_headers('text/html', msglen,
@@ -13637,7 +13644,7 @@ class PubServer(BaseHTTPRequestHandler):
13637 13644
 
13638 13645
         # check authorization
13639 13646
         authorized = self._isAuthorized()
13640
-        if not authorized:
13647
+        if not authorized and self.server.debug:
13641 13648
             print('POST Not authorized')
13642 13649
             print(str(self.headers))
13643 13650
 
@@ -14236,7 +14243,8 @@ class PubServer(BaseHTTPRequestHandler):
14236 14243
             return
14237 14244
         else:
14238 14245
             if self.path == '/sharedInbox' or self.path == '/inbox':
14239
-                print('DEBUG: POST to shared inbox')
14246
+                if self.server.debug:
14247
+                    print('DEBUG: POST to shared inbox')
14240 14248
                 queueStatus = \
14241 14249
                     self._updateInboxQueue('inbox', messageJson, messageBytes)
14242 14250
                 if queueStatus >= 0 and queueStatus <= 3:

+ 1
- 1
delete.py View File

@@ -55,7 +55,7 @@ def sendDeleteViaServer(baseDir: str, session,
55 55
     # lookup the inbox for the To handle
56 56
     wfRequest = \
57 57
         webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
58
-                        fromDomain, projectVersion)
58
+                        fromDomain, projectVersion, debug)
59 59
     if not wfRequest:
60 60
         if debug:
61 61
             print('DEBUG: announce webfinger failed for ' + handle)

+ 1
- 1
epicyon.py View File

@@ -1477,7 +1477,7 @@ if args.followers:
1477 1477
     handle = nickname + '@' + domain
1478 1478
     wfRequest = webfingerHandle(session, handle,
1479 1479
                                 httpPrefix, cachedWebfingers,
1480
-                                None, __version__)
1480
+                                None, __version__, debug)
1481 1481
     if not wfRequest:
1482 1482
         print('Unable to webfinger ' + handle)
1483 1483
         sys.exit()

+ 2
- 2
follow.py View File

@@ -989,7 +989,7 @@ def sendFollowRequestViaServer(baseDir: str, session,
989 989
     # lookup the inbox for the To handle
990 990
     wfRequest = \
991 991
         webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
992
-                        fromDomain, projectVersion)
992
+                        fromDomain, projectVersion, debug)
993 993
     if not wfRequest:
994 994
         if debug:
995 995
             print('DEBUG: announce webfinger failed for ' + handle)
@@ -1078,7 +1078,7 @@ def sendUnfollowRequestViaServer(baseDir: str, session,
1078 1078
     # lookup the inbox for the To handle
1079 1079
     wfRequest = \
1080 1080
         webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
1081
-                        fromDomain, projectVersion)
1081
+                        fromDomain, projectVersion, debug)
1082 1082
     if not wfRequest:
1083 1083
         if debug:
1084 1084
             print('DEBUG: announce webfinger failed for ' + handle)

+ 7
- 6
inbox.py View File

@@ -2702,7 +2702,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
2702 2702
                 queue.pop(0)
2703 2703
             continue
2704 2704
 
2705
-        print('Loading queue item ' + queueFilename)
2705
+        if debug:
2706
+            print('Loading queue item ' + queueFilename)
2706 2707
 
2707 2708
         # Load the queue json
2708 2709
         queueJson = loadJson(queueFilename, 1)
@@ -2829,7 +2830,7 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
2829 2830
                 if accountMaxPostsPerDay > 0 or domainMaxPostsPerDay > 0:
2830 2831
                     pprint(quotasDaily)
2831 2832
 
2832
-        if queueJson.get('actor'):
2833
+        if debug and queueJson.get('actor'):
2833 2834
             print('Obtaining public key for actor ' + queueJson['actor'])
2834 2835
 
2835 2836
         # Try a few times to obtain the public key
@@ -3053,8 +3054,9 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
3053 3054
                                  httpPrefix, domain, port, debug)
3054 3055
         if len(recipientsDict.items()) == 0 and \
3055 3056
            len(recipientsDictFollowers.items()) == 0:
3056
-            print('Queue: no recipients were resolved ' +
3057
-                  'for post arriving in inbox')
3057
+            if debug:
3058
+                print('Queue: no recipients were resolved ' +
3059
+                      'for post arriving in inbox')
3058 3060
             if os.path.isfile(queueFilename):
3059 3061
                 os.remove(queueFilename)
3060 3062
             if len(queue) > 0:
@@ -3122,8 +3124,7 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
3122 3124
                                themeName)
3123 3125
             if debug:
3124 3126
                 pprint(queueJson['post'])
3125
-
3126
-            print('Queue: Queue post accepted')
3127
+                print('Queue: Queue post accepted')
3127 3128
         if os.path.isfile(queueFilename):
3128 3129
             os.remove(queueFilename)
3129 3130
         if len(queue) > 0:

+ 2
- 2
like.py View File

@@ -167,7 +167,7 @@ def sendLikeViaServer(baseDir: str, session,
167 167
     # lookup the inbox for the To handle
168 168
     wfRequest = webfingerHandle(session, handle, httpPrefix,
169 169
                                 cachedWebfingers,
170
-                                fromDomain, projectVersion)
170
+                                fromDomain, projectVersion, debug)
171 171
     if not wfRequest:
172 172
         if debug:
173 173
             print('DEBUG: announce webfinger failed for ' + handle)
@@ -248,7 +248,7 @@ def sendUndoLikeViaServer(baseDir: str, session,
248 248
     # lookup the inbox for the To handle
249 249
     wfRequest = webfingerHandle(session, handle, httpPrefix,
250 250
                                 cachedWebfingers,
251
-                                fromDomain, projectVersion)
251
+                                fromDomain, projectVersion, debug)
252 252
     if not wfRequest:
253 253
         if debug:
254 254
             print('DEBUG: announce webfinger failed for ' + handle)

+ 1
- 1
migrate.py View File

@@ -56,7 +56,7 @@ def _updateMovedHandle(baseDir: str, nickname: str, domain: str,
56 56
         handle = handle[1:]
57 57
     wfRequest = webfingerHandle(session, handle,
58 58
                                 httpPrefix, cachedWebfingers,
59
-                                None, __version__)
59
+                                None, __version__, debug)
60 60
     if not wfRequest:
61 61
         print('updateMovedHandle unable to webfinger ' + handle)
62 62
         return ctr

+ 3
- 2
person.py View File

@@ -1102,7 +1102,8 @@ def setPersonNotes(baseDir: str, nickname: str, domain: str,
1102 1102
     return True
1103 1103
 
1104 1104
 
1105
-def getActorJson(handle: str, http: bool, gnunet: bool, quiet=False) -> {}:
1105
+def getActorJson(handle: str, http: bool, gnunet: bool,
1106
+                 debug: bool, quiet=False) -> {}:
1106 1107
     """Returns the actor json
1107 1108
     """
1108 1109
     originalActor = handle
@@ -1175,7 +1176,7 @@ def getActorJson(handle: str, http: bool, gnunet: bool, quiet=False) -> {}:
1175 1176
     handle = nickname + '@' + domain
1176 1177
     wfRequest = webfingerHandle(session, handle,
1177 1178
                                 httpPrefix, cachedWebfingers,
1178
-                                None, __version__)
1179
+                                None, __version__, debug)
1179 1180
     if not wfRequest:
1180 1181
         if not quiet:
1181 1182
             print('Unable to webfinger ' + handle)

+ 14
- 13
posts.py View File

@@ -1935,7 +1935,7 @@ def sendPost(projectVersion: str,
1935 1935
     # lookup the inbox for the To handle
1936 1936
     wfRequest = webfingerHandle(session, handle, httpPrefix,
1937 1937
                                 cachedWebfingers,
1938
-                                domain, projectVersion)
1938
+                                domain, projectVersion, debug)
1939 1939
     if not wfRequest:
1940 1940
         return 1
1941 1941
     if not isinstance(wfRequest, dict):
@@ -2052,7 +2052,7 @@ def sendPostViaServer(projectVersion: str,
2052 2052
     # lookup the inbox for the To handle
2053 2053
     wfRequest = \
2054 2054
         webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
2055
-                        fromDomain, projectVersion)
2055
+                        fromDomain, projectVersion, debug)
2056 2056
     if not wfRequest:
2057 2057
         if debug:
2058 2058
             print('DEBUG: webfinger failed for ' + handle)
@@ -2249,7 +2249,7 @@ def sendSignedJson(postJsonObject: {}, session, baseDir: str,
2249 2249
 
2250 2250
     # lookup the inbox for the To handle
2251 2251
     wfRequest = webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
2252
-                                domain, projectVersion)
2252
+                                domain, projectVersion, debug)
2253 2253
     if not wfRequest:
2254 2254
         if debug:
2255 2255
             print('DEBUG: webfinger for ' + handle + ' failed')
@@ -2538,7 +2538,8 @@ def sendToNamedAddresses(session, baseDir: str,
2538 2538
                        personCache, debug, projectVersion)
2539 2539
 
2540 2540
 
2541
-def _hasSharedInbox(session, httpPrefix: str, domain: str) -> bool:
2541
+def _hasSharedInbox(session, httpPrefix: str, domain: str,
2542
+                    debug: bool) -> bool:
2542 2543
     """Returns true if the given domain has a shared inbox
2543 2544
     This tries the new and the old way of webfingering the shared inbox
2544 2545
     """
@@ -2547,9 +2548,8 @@ def _hasSharedInbox(session, httpPrefix: str, domain: str) -> bool:
2547 2548
         'inbox@' + domain
2548 2549
     ]
2549 2550
     for handle in tryHandles:
2550
-        wfRequest = webfingerHandle(session, handle,
2551
-                                    httpPrefix, {},
2552
-                                    None, __version__)
2551
+        wfRequest = webfingerHandle(session, handle, httpPrefix, {},
2552
+                                    None, __version__, debug)
2553 2553
         if wfRequest:
2554 2554
             if isinstance(wfRequest, dict):
2555 2555
                 if not wfRequest.get('errors'):
@@ -2634,7 +2634,8 @@ def sendToFollowers(session, baseDir: str,
2634 2634
         print('Sending post to followers domain is active: ' +
2635 2635
               followerDomainUrl)
2636 2636
 
2637
-        withSharedInbox = _hasSharedInbox(session, httpPrefix, followerDomain)
2637
+        withSharedInbox = _hasSharedInbox(session, httpPrefix,
2638
+                                          followerDomain, debug)
2638 2639
         if debug:
2639 2640
             if withSharedInbox:
2640 2641
                 print(followerDomain + ' has shared inbox')
@@ -3463,7 +3464,7 @@ def getPublicPostsOfPerson(baseDir: str, nickname: str, domain: str,
3463 3464
     handle = httpPrefix + "://" + domainFull + "/@" + nickname
3464 3465
     wfRequest = \
3465 3466
         webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
3466
-                        domain, projectVersion)
3467
+                        domain, projectVersion, debug)
3467 3468
     if not wfRequest:
3468 3469
         sys.exit()
3469 3470
     if not isinstance(wfRequest, dict):
@@ -3505,7 +3506,7 @@ def getPublicPostDomains(session, baseDir: str, nickname: str, domain: str,
3505 3506
     handle = httpPrefix + "://" + domainFull + "/@" + nickname
3506 3507
     wfRequest = \
3507 3508
         webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
3508
-                        domain, projectVersion)
3509
+                        domain, projectVersion, debug)
3509 3510
     if not wfRequest:
3510 3511
         return domainList
3511 3512
     if not isinstance(wfRequest, dict):
@@ -3585,7 +3586,7 @@ def getPublicPostInfo(session, baseDir: str, nickname: str, domain: str,
3585 3586
     handle = httpPrefix + "://" + domainFull + "/@" + nickname
3586 3587
     wfRequest = \
3587 3588
         webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
3588
-                        domain, projectVersion)
3589
+                        domain, projectVersion, debug)
3589 3590
     if not wfRequest:
3590 3591
         return {}
3591 3592
     if not isinstance(wfRequest, dict):
@@ -4148,7 +4149,7 @@ def sendBlockViaServer(baseDir: str, session,
4148 4149
     # lookup the inbox for the To handle
4149 4150
     wfRequest = webfingerHandle(session, handle, httpPrefix,
4150 4151
                                 cachedWebfingers,
4151
-                                fromDomain, projectVersion)
4152
+                                fromDomain, projectVersion, debug)
4152 4153
     if not wfRequest:
4153 4154
         if debug:
4154 4155
             print('DEBUG: announce webfinger failed for ' + handle)
@@ -4232,7 +4233,7 @@ def sendUndoBlockViaServer(baseDir: str, session,
4232 4233
     # lookup the inbox for the To handle
4233 4234
     wfRequest = webfingerHandle(session, handle, httpPrefix,
4234 4235
                                 cachedWebfingers,
4235
-                                fromDomain, projectVersion)
4236
+                                fromDomain, projectVersion, debug)
4236 4237
     if not wfRequest:
4237 4238
         if debug:
4238 4239
             print('DEBUG: announce webfinger failed for ' + handle)

+ 1
- 1
roles.py View File

@@ -310,7 +310,7 @@ def sendRoleViaServer(baseDir: str, session,
310 310
     # lookup the inbox for the To handle
311 311
     wfRequest = webfingerHandle(session, handle, httpPrefix,
312 312
                                 cachedWebfingers,
313
-                                delegatorDomain, projectVersion)
313
+                                delegatorDomain, projectVersion, debug)
314 314
     if not wfRequest:
315 315
         if debug:
316 316
             print('DEBUG: announce webfinger failed for ' + handle)

+ 2
- 2
shares.py View File

@@ -358,7 +358,7 @@ def sendShareViaServer(baseDir, session,
358 358
     wfRequest = \
359 359
         webfingerHandle(session, handle, httpPrefix,
360 360
                         cachedWebfingers,
361
-                        fromDomain, projectVersion)
361
+                        fromDomain, projectVersion, debug)
362 362
     if not wfRequest:
363 363
         if debug:
364 364
             print('DEBUG: announce webfinger failed for ' + handle)
@@ -457,7 +457,7 @@ def sendUndoShareViaServer(baseDir: str, session,
457 457
     # lookup the inbox for the To handle
458 458
     wfRequest = \
459 459
         webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
460
-                        fromDomain, projectVersion)
460
+                        fromDomain, projectVersion, debug)
461 461
     if not wfRequest:
462 462
         if debug:
463 463
             print('DEBUG: announce webfinger failed for ' + handle)

+ 1
- 1
skills.py View File

@@ -123,7 +123,7 @@ def sendSkillViaServer(baseDir: str, session, nickname: str, password: str,
123 123
     wfRequest = \
124 124
         webfingerHandle(session, handle, httpPrefix,
125 125
                         cachedWebfingers,
126
-                        domain, projectVersion)
126
+                        domain, projectVersion, debug)
127 127
     if not wfRequest:
128 128
         if debug:
129 129
             print('DEBUG: announce webfinger failed for ' + handle)

+ 1
- 1
socnet.py View File

@@ -52,7 +52,7 @@ def instancesGraph(baseDir: str, handles: str,
52 52
         wfRequest = \
53 53
             webfingerHandle(session, handle, httpPrefix,
54 54
                             cachedWebfingers,
55
-                            domain, projectVersion)
55
+                            domain, projectVersion, debug)
56 56
         if not wfRequest:
57 57
             return dotGraphStr + '}\n'
58 58
         if not isinstance(wfRequest, dict):

+ 1
- 1
webapp_post.py View File

@@ -1223,7 +1223,7 @@ def individualPostAsHtml(allowDownloads: bool,
1223 1223
         postActorWf = \
1224 1224
             webfingerHandle(session, postActorHandle, httpPrefix,
1225 1225
                             cachedWebfingers,
1226
-                            domain, __version__)
1226
+                            domain, __version__, False)
1227 1227
 
1228 1228
         avatarUrl2 = None
1229 1229
         displayName = None

+ 8
- 6
webapp_profile.py View File

@@ -115,7 +115,7 @@ def htmlProfileAfterSearch(cssCache: {},
115 115
         webfingerHandle(session,
116 116
                         searchNickname + '@' + searchDomainFull,
117 117
                         httpPrefix, cachedWebfingers,
118
-                        domain, projectVersion)
118
+                        domain, projectVersion, debug)
119 119
     if not wf:
120 120
         print('DEBUG: Unable to webfinger ' +
121 121
               searchNickname + '@' + searchDomainFull)
@@ -481,6 +481,7 @@ def htmlProfile(rssIconAtTop: bool,
481 481
                 peertubeInstances: [],
482 482
                 allowLocalNetworkAccess: bool,
483 483
                 textModeBanner: str,
484
+                debug: bool,
484 485
                 extraJson=None, pageNumber=None,
485 486
                 maxItemsPerPage=None) -> str:
486 487
     """Show the profile page as html
@@ -816,7 +817,7 @@ def htmlProfile(rssIconAtTop: bool,
816 817
                                   cachedWebfingers, personCache, extraJson,
817 818
                                   projectVersion, ["unfollow"], selected,
818 819
                                   usersPath, pageNumber, maxItemsPerPage,
819
-                                  dormantMonths)
820
+                                  dormantMonths, debug)
820 821
     elif selected == 'followers':
821 822
         profileStr += \
822 823
             _htmlProfileFollowing(translate, baseDir, httpPrefix,
@@ -825,7 +826,7 @@ def htmlProfile(rssIconAtTop: bool,
825 826
                                   cachedWebfingers, personCache, extraJson,
826 827
                                   projectVersion, ["block"],
827 828
                                   selected, usersPath, pageNumber,
828
-                                  maxItemsPerPage, dormantMonths)
829
+                                  maxItemsPerPage, dormantMonths, debug)
829 830
     elif selected == 'roles':
830 831
         profileStr += \
831 832
             _htmlProfileRoles(translate, nickname, domainFull,
@@ -920,7 +921,7 @@ def _htmlProfileFollowing(translate: {}, baseDir: str, httpPrefix: str,
920 921
                           feedName: str, actor: str,
921 922
                           pageNumber: int,
922 923
                           maxItemsPerPage: int,
923
-                          dormantMonths: int) -> str:
924
+                          dormantMonths: int, debug: bool) -> str:
924 925
     """Shows following on the profile screen
925 926
     """
926 927
     profileStr = ''
@@ -952,7 +953,7 @@ def _htmlProfileFollowing(translate: {}, baseDir: str, httpPrefix: str,
952 953
                                     domain, followingActor,
953 954
                                     authorized, nickname,
954 955
                                     httpPrefix, projectVersion, dormant,
955
-                                    buttons)
956
+                                    debug, buttons)
956 957
 
957 958
     if authorized and maxItemsPerPage and pageNumber:
958 959
         if len(followingJson['orderedItems']) >= maxItemsPerPage:
@@ -1801,6 +1802,7 @@ def _individualFollowAsHtml(translate: {},
1801 1802
                             httpPrefix: str,
1802 1803
                             projectVersion: str,
1803 1804
                             dormant: bool,
1805
+                            debug: bool,
1804 1806
                             buttons=[]) -> str:
1805 1807
     """An individual follow entry on the profile screen
1806 1808
     """
@@ -1817,7 +1819,7 @@ def _individualFollowAsHtml(translate: {},
1817 1819
     followUrlWf = \
1818 1820
         webfingerHandle(session, followUrlHandle, httpPrefix,
1819 1821
                         cachedWebfingers,
1820
-                        domain, __version__)
1822
+                        domain, __version__, debug)
1821 1823
 
1822 1824
     (inboxUrl, pubKeyId, pubKey,
1823 1825
      fromPersonId, sharedInbox,

+ 12
- 8
webfinger.py View File

@@ -40,11 +40,13 @@ def _parseHandle(handle: str) -> (str, str):
40 40
 
41 41
 def webfingerHandle(session, handle: str, httpPrefix: str,
42 42
                     cachedWebfingers: {},
43
-                    fromDomain: str, projectVersion: str) -> {}:
43
+                    fromDomain: str, projectVersion: str,
44
+                    debug: bool) -> {}:
44 45
     """Gets webfinger result for the given ActivityPub handle
45 46
     """
46 47
     if not session:
47
-        print('WARN: No session specified for webfingerHandle')
48
+        if debug:
49
+            print('WARN: No session specified for webfingerHandle')
48 50
         return None
49 51
 
50 52
     nickname, domain = _parseHandle(handle)
@@ -60,7 +62,8 @@ def webfingerHandle(session, handle: str, httpPrefix: str,
60 62
     wf = getWebfingerFromCache(nickname + '@' + wfDomain,
61 63
                                cachedWebfingers)
62 64
     if wf:
63
-        print('Webfinger from cache: ' + str(wf))
65
+        if debug:
66
+            print('Webfinger from cache: ' + str(wf))
64 67
         return wf
65 68
     url = '{}://{}/.well-known/webfinger'.format(httpPrefix, domain)
66 69
     par = {
@@ -81,11 +84,12 @@ def webfingerHandle(session, handle: str, httpPrefix: str,
81 84
         storeWebfingerInCache(nickname + '@' + wfDomain,
82 85
                               result, cachedWebfingers)
83 86
     else:
84
-        print("WARN: Unable to webfinger " + url + ' ' +
85
-              'nickname: ' + str(nickname) + ' ' +
86
-              'domain: ' + str(wfDomain) + ' ' +
87
-              'headers: ' + str(hdr) + ' ' +
88
-              'params: ' + str(par))
87
+        if debug:
88
+            print("WARN: Unable to webfinger " + url + ' ' +
89
+                  'nickname: ' + str(nickname) + ' ' +
90
+                  'domain: ' + str(wfDomain) + ' ' +
91
+                  'headers: ' + str(hdr) + ' ' +
92
+                  'params: ' + str(par))
89 93
 
90 94
     return result
91 95
 

Loading…
Cancel
Save