Exemplo n.º 1
0
def set_proxy():
    # Free PythonAnywhere accounts are blocked from external IP access,
    # except through proxy whitelist
    # See: https://www.pythonanywhere.com/forums/topic/3854/
    proxy_url = os.environ.get("http_proxy")
    host, port = urlparse(proxy_url).netloc.split(":")
    Connection.set_proxy_info(host, int(port), proxy_type=PROXY_TYPE_HTTP)
Exemplo n.º 2
0
def set_twilio_proxy(proxy_url, proxy_port):
    Connection.set_proxy_info(proxy_url, proxy_port)
Exemplo n.º 3
0
import os
from urlparse import urlparse

from django.core.mail import send_mail, send_mass_mail
from twilio.rest import TwilioRestClient
from twilio.rest.resources import Connection
from twilio.rest.resources.connection import PROXY_TYPE_HTTP

proxy_url = os.environ.get("http_proxy")
host, port = urlparse(proxy_url).netloc.split(":")
Connection.set_proxy_info(host, int(port), proxy_type=PROXY_TYPE_HTTP)

from django.contrib.auth.models import User
from django.db import models
from django import forms
from django.forms import ModelForm
from django.contrib.admin.widgets import AdminDateWidget

from django.core.validators import RegexValidator

from datetime import datetime, date, time, timedelta
from django.utils import timezone

class ActiveUserManager(models.Manager):
    def get_queryset(self):
        return super(ActiveUserManager, self).get_queryset().filter(active=True)

class InactiveUserManager(models.Manager):
    def get_queryset(self):
        return super(InactiveUserManager, self).get_queryset().filter(active=False)
Exemplo n.º 4
0
 def __init__(self, sid=None, token=None):
     host, port = urlparse(os.environ["http_proxy"]).netloc.split(":")
     Connection.set_proxy_info(host, int(port), proxy_type=PROXY_TYPE_HTTP)
     self.twilio_client = TwilioRestClient(sid, token)
Exemplo n.º 5
0
from twilio.rest.resources.connection  import PROXY_TYPE_SOCKS5, PROXY_TYPE_HTTP
import sys



# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = conf['auth']['AuthSid']
auth_token  = conf['auth']['AuthToken']

#-----------------------------------------------------------------------------------------
# Proxy settings, like you want, use PROXY_TYPE_SOCKS5 for socks proxy
if (conf['proxy']['use_proxy']==1):
    if (conf['proxy']['ProxyType'] == "HTTP"):
        Connection.set_proxy_info(
            str(conf['proxy']['Proxy']),
            conf['proxy']['Port'],
            proxy_type=PROXY_TYPE_HTTP,
            )

    else:
        Connection.set_proxy_info(
            str(conf['proxy']['Proxy']),  #proxy server
            conf['proxy']['Port'],               #port
            proxy_type=PROXY_TYPE_SOCKS5)
else:
    pass
#-----------------------------------------------------------------------------------------

client = TwilioRestClient(account_sid, auth_token)

def print_error():