Changeset - b4d763546411
[Not reviewed]
default
0 2 0
Dennis Fink - 11 years ago 2014-01-24 00:24:24
dennis.fink@c3l.lu
pep8
2 files changed with 4 insertions and 2 deletions:
0 comments (0 inline, 0 general)
Scripts/update_server.py
Show inline comments
 
import subprocess
 
import configparser
 
import re
 
import json
 

	
 
import requests
 

	
 
from ast import literal_eval
 

	
 
OBFS_REGEX = re.compile(r'^ServerTransportPlugin obfs2,obfs3')
 

	
 
IP_REGEX = re.compile(r'^(OutboundBindAddress)\ (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})')
 
IP_REGEX = re.compile(r'^(OutboundBindAddress)\ (\d{1,3}\.\d{1,3}\.\d{1,3}\.'
 
                      r'\d{1,3})')
 

	
 

	
 
def read_tor_config(configfile="/etc/tor/torrc"):
 

	
 
    with open(configfile) as fb:
 
        lines = {line[:-1] for line in fb if not line.startswith('#')}
 

	
 
    lines = {line for line in filter(None, lines)}
 
    return lines
 

	
 

	
 
def get_tor_status(name='tor'):
 

	
 
    try:
 
        pids = subprocess.check_output(['pidof', 'tor']).decode('utf-8')[:-1]
 
        pids = pids.split(' ')
 
        pid_file = '.'.join([name, 'pid'])
 
        pid = open('/'.join(['/var', 'run', 'tor', pid_file])).readline()[:-1]
 

	
 
        if str(pid) in pids:
 
            return "Online"
 
        else:
 
            return "Offline"
 
    except subprocess.CalledProcessError:
 
        return "Offline"
 

	
 

	
 
def get_tor_fingerprint(name='tor'):
 

	
 
    fingerprint_file = '/'.join(['/var', 'lib', name, 'fingerprint'])
 

	
 
    with open(fingerprint_file) as fb:
 
        line = fb.readline()[:-1]
 

	
 
    hostname, fingerprint = line.split(' ')
 
    return hostname, fingerprint
 

	
 

	
 
def get_server_type(tor_config):
 

	
 
    if 'BridgeRelay 1' in tor_config:
 
        if any(OBFS_REGEX.match(i) for i in tor_config):
 
            return 'Bridge', 'True'
 
        else:
 
            return 'Bridge', 'False'
 
    elif 'ExitPolicy reject *:*' in tor_config:
 
        return 'Relay', None
 
    else:
setup.py
Show inline comments
 
from setuptools import setup, find_packages
 

	
 
setup(name='Ennstatus',
 
      version='4.0.1',
 
      description='Ennstatus provides the user with vital information about the status of the organizations Tor servers.',
 
      description=('Ennstatus provides the user with vital information about '
 
                   'the status of the organizations Tor servers.'),
 
      author='Frënn vun der Ënn',
 
      author_email='info@enn.lu',
 
      url='https://bitbucket.org/fvde/ennstatus',
 
      license="GPLv3+",
 
      packages=find_packages(),
 
      package_data={'ennstatus': ['static/css/*.css',
 
                                  'static/css/flags/img/png/*.png',
 
                                  'static/css/flags/img/gif/*.gif',
 
                                  'static/css/flags/*.css',
 
                                  'static/files/*',
 
                                  'static/images/*',
 
                                  'static/videos/*',
 
                                  'templates/*.html',
 
                                  'templates/api/extract/xml/*.xml',
 
                                  'templates/donate/*.html',
 
                                  'templates/root/*.html',
 
                                  'templates/status/*.html',
 
                                  'templates/stats/*.html'
 
                                  ]},
 
      install_requires=['Flask', 'pygeoip', 'Flask-Bootstrap',
 
                        'Flask-Compress', 'Flask-SSLify', 'Flask-WTF'],
 
      classifiers=["Development Status :: 5 - Production/Stable",
 
                   "Environment :: Web Environment",
 
                   "Operating System :: POSIX",
 
                   "Programming Language :: Python",
 
                   "Programming Language :: Python :: 2",
 
                   "Programming Language :: Python :: 2.7",
 
                   "Topic :: Internet",
 
                   "Topic :: Internet :: WWW/HTTP",
 
                   "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
 
                   "Topic :: Internet :: WWW/HTTP :: WSGI",
 
                   "Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
 
                   ("License :: OSI Approved :: "
 
                    "GNU General Public License v3 or later (GPLv3+)"),
 
                   ]
 
      )
0 comments (0 inline, 0 general)