forked from indymedia/epicyon
				
			qrcode dependencies on parabola
							parent
							
								
									4587ce6771
								
							
						
					
					
						commit
						dc9ae0c117
					
				| 
						 | 
				
			
			@ -22,8 +22,8 @@ On Arch/Parabola:
 | 
			
		|||
sudo pacman -S tor python-pip python-pysocks python-pycryptodome \
 | 
			
		||||
               imagemagick python-pillow python-requests \
 | 
			
		||||
	       perl-image-exiftool python-numpy python-dateutil \
 | 
			
		||||
	       python-qrcode python-png certbot flake8
 | 
			
		||||
suso pip3 install pyLD
 | 
			
		||||
	       certbot flake8
 | 
			
		||||
sudo pip3 install pyLD pyqrcode pypng
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Or on Debian:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -57,8 +57,8 @@ if [ -f /usr/bin/pacman ]; then
 | 
			
		|||
    pacman -S --noconfirm python-pip python-pysocks python-pycryptodome \
 | 
			
		||||
           imagemagick python-pillow python-requests \
 | 
			
		||||
	   perl-image-exiftool python-numpy python-dateutil \
 | 
			
		||||
	   python-qrcode certbot flake8 git i2pd wget qrencode
 | 
			
		||||
    pip3 install pyLD
 | 
			
		||||
	   certbot flake8 git i2pd wget qrencode
 | 
			
		||||
    pip3 install pyLD pyqrcode pypng
 | 
			
		||||
else
 | 
			
		||||
    apt-get update
 | 
			
		||||
    apt-get -y install imagemagick python3-crypto python3-pycryptodome \
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,8 +38,8 @@ if [ -f /usr/bin/pacman ]; then
 | 
			
		|||
    pacman -S --noconfirm tor python-pip python-pysocks python-pycryptodome \
 | 
			
		||||
           imagemagick python-pillow python-requests \
 | 
			
		||||
	   perl-image-exiftool python-numpy python-dateutil \
 | 
			
		||||
	   python-qrcode certbot flake8 git qrencode
 | 
			
		||||
    pip3 install pyLD
 | 
			
		||||
	   certbot flake8 git qrencode
 | 
			
		||||
    pip3 install pyLD pyqrcode pypng
 | 
			
		||||
else
 | 
			
		||||
    apt-get update
 | 
			
		||||
    apt-get -y install imagemagick python3-crypto python3-pycryptodome \
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										8
									
								
								tests.py
								
								
								
								
							
							
						
						
									
										8
									
								
								tests.py
								
								
								
								
							| 
						 | 
				
			
			@ -31,6 +31,7 @@ from follow import clearFollows
 | 
			
		|||
from follow import clearFollowers
 | 
			
		||||
from follow import sendFollowRequestViaServer
 | 
			
		||||
from follow import sendUnfollowRequestViaServer
 | 
			
		||||
from utils import siteIsActive
 | 
			
		||||
from utils import updateRecentPostsCache
 | 
			
		||||
from utils import followPerson
 | 
			
		||||
from utils import getNicknameFromActor
 | 
			
		||||
| 
						 | 
				
			
			@ -1858,8 +1859,15 @@ def testJsonld():
 | 
			
		|||
    assert(jsonldVerify(signedDocument, publicKeyPem))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def testSiteIsActive():
 | 
			
		||||
    print('testSiteIsActive')
 | 
			
		||||
    assert(siteIsActive('https://mastodon.social'))
 | 
			
		||||
    assert(not siteIsActive('https://notarealwebsite.a.b.c'))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def runAllTests():
 | 
			
		||||
    print('Running tests...')
 | 
			
		||||
    testSiteIsActive()
 | 
			
		||||
    testJsonld()
 | 
			
		||||
    testRemoveTextFormatting()
 | 
			
		||||
    testWebLinks()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										14
									
								
								utils.py
								
								
								
								
							
							
						
						
									
										14
									
								
								utils.py
								
								
								
								
							| 
						 | 
				
			
			@ -11,6 +11,8 @@ import time
 | 
			
		|||
import shutil
 | 
			
		||||
import datetime
 | 
			
		||||
import json
 | 
			
		||||
from urllib.request import urlopen
 | 
			
		||||
from urllib.request import URLError
 | 
			
		||||
from pprint import pprint
 | 
			
		||||
from calendar import monthrange
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1066,3 +1068,15 @@ def updateAnnounceCollection(recentPostsCache: {},
 | 
			
		|||
            print('DEBUG: saving post with shares (announcements) added')
 | 
			
		||||
            pprint(postJsonObject)
 | 
			
		||||
        saveJson(postJsonObject, postFilename)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def siteIsActive(url: str) -> bool:
 | 
			
		||||
    """Returns true if the current url is resolvable.
 | 
			
		||||
    This can be used to check that an instance is online before
 | 
			
		||||
    trying to send posts to it.
 | 
			
		||||
    """
 | 
			
		||||
    try:
 | 
			
		||||
        urlopen(url, timeout=10)
 | 
			
		||||
        return True
 | 
			
		||||
    except URLError as err:
 | 
			
		||||
        return False
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue