code stringlengths 1 1.72M | language stringclasses 1
value |
|---|---|
#!/usr/bin/python
import time, os, stat, random, sys, logging, socket, shutil, tempfile
from binascii import crc32
from StringIO import StringIO
from twisted.python import failure
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(
os.path.abspath(__file__)))))
from flud.FludNode import FludNode
from... | Python |
#!/usr/bin/python
"""
FludFileOpTest.py, (c) 2003-2006 Alen Peacock. This program is distributed
under the terms of the GNU General Public License (the GPL), version 3.
System tests for FludFileOperations
"""
import sys, os, time, logging, tempfile, shutil
from twisted.internet import reactor
sys.path.append(os.p... | Python |
#!/usr/bin/python
import time, os, stat, random, sys, logging, socket
from twisted.python import failure
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(
os.path.abspath(__file__)))))
from flud.FludNode import FludNode
from flud.protocol.FludClient import FludClient
from flud.protocol.FludCommUtil... | Python |
#!/usr/bin/python
import tarfile, tempfile, random, os, sys
import gzip
from Crypto.Hash import SHA256
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(
os.path.abspath(__file__)))))
from flud.fencode import fencode
import flud.TarfileUtils as TarfileUtils
def maketarball(numfiles, avgsize, hashna... | Python |
#!/usr/bin/python
import time, os, stat, random, sys, logging, socket
from twisted.python import failure
from twisted.internet import defer
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(
os.path.abspath(__file__)))))
import flud.FludCrypto
from flud.FludNode import FludNode
from flud.protocol.Fl... | Python |
#!/usr/bin/python
import time, os, stat, random, sys, logging, socket, tempfile
from twisted.python import failure
from StringIO import StringIO
from zlib import crc32
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(
os.path.abspath(__file__)))))
from flud.FludNode import FludNode
from flud.protoc... | Python |
#!/usr/bin/python
import time, os, stat, random, sys, logging, socket
from twisted.python import failure
from twisted.internet import defer
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(
os.path.abspath(__file__)))))
import flud.FludCrypto
from flud.FludNode import FludNode
from flud.protocol.Fl... | Python |
#!/usr/bin/python
import tarfile, tempfile, random, os, sys
import gzip
from Crypto.Hash import SHA256
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(
os.path.abspath(__file__)))))
from flud.fencode import fencode
import flud.TarfileUtils as TarfileUtils
def maketarball(numfiles, avgsize, hashna... | Python |
#!/usr/bin/env python
"""
FCKeditor - The text editor for Internet - http://www.fckeditor.net
Copyright (C) 2003-2010 Frederico Caldeira Knabben
== BEGIN LICENSE ==
Licensed under the terms of any of the following licenses at your
choice:
- GNU General Public License Version 2 or later (the "GPL")
http:... | Python |
#!/usr/bin/env python
"""
FCKeditor - The text editor for Internet - http://www.fckeditor.net
Copyright (C) 2003-2010 Frederico Caldeira Knabben
== BEGIN LICENSE ==
Licensed under the terms of any of the following licenses at your
choice:
- GNU General Public License Version 2 or later (the "GPL")
http:... | Python |
#!/usr/bin/env python
"""
FCKeditor - The text editor for Internet - http://www.fckeditor.net
Copyright (C) 2003-2010 Frederico Caldeira Knabben
== BEGIN LICENSE ==
Licensed under the terms of any of the following licenses at your
choice:
- GNU General Public License Version 2 or later (the "GPL")
http:... | Python |
#!/usr/bin/env python
"""
FCKeditor - The text editor for Internet - http://www.fckeditor.net
Copyright (C) 2003-2010 Frederico Caldeira Knabben
== BEGIN LICENSE ==
Licensed under the terms of any of the following licenses at your
choice:
- GNU General Public License Version 2 or later (the "GPL")
http:... | Python |
#!/usr/bin/env python
"""
FCKeditor - The text editor for Internet - http://www.fckeditor.net
Copyright (C) 2003-2010 Frederico Caldeira Knabben
== BEGIN LICENSE ==
Licensed under the terms of any of the following licenses at your
choice:
- GNU General Public License Version 2 or later (the "GPL")
http:... | Python |
#!/usr/bin/env python
"""
FCKeditor - The text editor for Internet - http://www.fckeditor.net
Copyright (C) 2003-2010 Frederico Caldeira Knabben
== BEGIN LICENSE ==
Licensed under the terms of any of the following licenses at your
choice:
- GNU General Public License Version 2 or later (the "GPL")
h... | Python |
#!/usr/bin/env python
"""
FCKeditor - The text editor for Internet - http://www.fckeditor.net
Copyright (C) 2003-2010 Frederico Caldeira Knabben
== BEGIN LICENSE ==
Licensed under the terms of any of the following licenses at your
choice:
- GNU General Public License Version 2 or later (the "GPL")
http:... | Python |
#!/usr/bin/env python
"""
FCKeditor - The text editor for Internet - http://www.fckeditor.net
Copyright (C) 2003-2010 Frederico Caldeira Knabben
== BEGIN LICENSE ==
Licensed under the terms of any of the following licenses at your
choice:
- GNU General Public License Version 2 or later (the "GPL")
h... | Python |
#!/usr/bin/env python
"""
FCKeditor - The text editor for Internet - http://www.fckeditor.net
Copyright (C) 2003-2010 Frederico Caldeira Knabben
== BEGIN LICENSE ==
Licensed under the terms of any of the following licenses at your
choice:
- GNU General Public License Version 2 or later (the "GPL")
http:... | Python |
#!/usr/bin/env python
"""
FCKeditor - The text editor for Internet - http://www.fckeditor.net
Copyright (C) 2003-2010 Frederico Caldeira Knabben
== BEGIN LICENSE ==
Licensed under the terms of any of the following licenses at your
choice:
- GNU General Public License Version 2 or later (the "GPL")
http:... | Python |
#!/usr/bin/env python
"""
FCKeditor - The text editor for Internet - http://www.fckeditor.net
Copyright (C) 2003-2010 Frederico Caldeira Knabben
== BEGIN LICENSE ==
Licensed under the terms of any of the following licenses at your
choice:
- GNU General Public License Version 2 or later (the "GPL")
http:... | Python |
#!/usr/bin/env python
"""
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2010 Frederico Caldeira Knabben
*
* == BEGIN LICENSE ==
*
* Licensed under the terms of any of the following licenses at your
* choice:
*
* - GNU General Public License Version 2 or l... | Python |
#!/usr/bin/env python
"""
FCKeditor - The text editor for Internet - http://www.fckeditor.net
Copyright (C) 2003-2010 Frederico Caldeira Knabben
== BEGIN LICENSE ==
Licensed under the terms of any of the following licenses at your
choice:
- GNU General Public License Version 2 or later (the "GPL")
http:... | Python |
#!/usr/bin/env python
"""
FCKeditor - The text editor for Internet - http://www.fckeditor.net
Copyright (C) 2003-2010 Frederico Caldeira Knabben
== BEGIN LICENSE ==
Licensed under the terms of any of the following licenses at your
choice:
- GNU General Public License Version 2 or later (the "GPL")
http:... | Python |
#!/usr/bin/env python
"""
FCKeditor - The text editor for Internet - http://www.fckeditor.net
Copyright (C) 2003-2010 Frederico Caldeira Knabben
== BEGIN LICENSE ==
Licensed under the terms of any of the following licenses at your
choice:
- GNU General Public License Version 2 or later (the "GPL")
http:... | Python |
#!/usr/bin/env python
"""
FCKeditor - The text editor for Internet - http://www.fckeditor.net
Copyright (C) 2003-2010 Frederico Caldeira Knabben
== BEGIN LICENSE ==
Licensed under the terms of any of the following licenses at your
choice:
- GNU General Public License Version 2 or later (the "GPL")
h... | Python |
#!/usr/bin/env python
"""
FCKeditor - The text editor for Internet - http://www.fckeditor.net
Copyright (C) 2003-2010 Frederico Caldeira Knabben
== BEGIN LICENSE ==
Licensed under the terms of any of the following licenses at your
choice:
- GNU General Public License Version 2 or later (the "GPL")
h... | Python |
#!/usr/bin/env python
"""
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2010 Frederico Caldeira Knabben
*
* == BEGIN LICENSE ==
*
* Licensed under the terms of any of the following licenses at your
* choice:
*
* - GNU General Public License Version 2 or l... | Python |
#!/usr/bin/python2.6
#
# Simple http server to emulate api.playfoursquare.com
import logging
import shutil
import sys
import urlparse
import SimpleHTTPServer
import BaseHTTPServer
class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
"""Handle playfoursquare.com requests, for testing."""
def do_GET(self... | Python |
#!/usr/bin/python
import os
import subprocess
import sys
BASEDIR = '../main/src/com/joelapenna/foursquare'
TYPESDIR = '../captures/types/v1'
captures = sys.argv[1:]
if not captures:
captures = os.listdir(TYPESDIR)
for f in captures:
basename = f.split('.')[0]
javaname = ''.join([c.capitalize() for c in basena... | Python |
#!/usr/bin/python
"""
Pull a oAuth protected page from foursquare.
Expects ~/.oget to contain (one on each line):
CONSUMER_KEY
CONSUMER_KEY_SECRET
USERNAME
PASSWORD
Don't forget to chmod 600 the file!
"""
import httplib
import os
import re
import sys
import urllib
import urllib2
import urlparse
import user
from xml.... | Python |
#!/usr/bin/python
import datetime
import sys
import textwrap
import common
from xml.dom import pulldom
PARSER = """\
/**
* Copyright 2009 Joe LaPenna
*/
package com.joelapenna.foursquare.parsers;
import com.joelapenna.foursquare.Foursquare;
import com.joelapenna.foursquare.error.FoursquareError;
import com.joel... | Python |
#!/usr/bin/python
import logging
from xml.dom import minidom
from xml.dom import pulldom
BOOLEAN = "boolean"
STRING = "String"
GROUP = "Group"
# Interfaces that all FoursquareTypes implement.
DEFAULT_INTERFACES = ['FoursquareType']
# Interfaces that specific FoursqureTypes implement.
INTERFACES = {
}
DEFAULT_CLA... | Python |
#!/usr/bin/python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run ... | Python |
#!/usr/bin/python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run ... | Python |
#!/usr/bin/env python
import os
os.system("python manage.py runserver 127.0.0.1:8000")
| Python |
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^api/', include('fluffycentral.api.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
(r'^admin/doc... | Python |
#!/usr/bin/env python
import os
os.system("python manage.py runserver 127.0.0.1:8000")
| Python |
# Django settings for fluffycentral project.
import os
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'pos... | Python |
from django.db import models
class ServiceProvider(models.Model):
name = models.CharField(max_length=200, unique=True)
address = models.CharField(max_length=20)
pubkey = models.CharField(max_length=2000)
def __unicode__(self):
return self.name
class File(models.Model):
name = models.C... | Python |
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
... | Python |
from repository.models import ServiceProvider, File
from django.contrib import admin
admin.site.register(ServiceProvider)
admin.site.register(File)
| Python |
# Create your views here.
| Python |
# -*- coding: utf-8 -*-
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist
from piston.handler import AnonymousBaseHandler, BaseHandler
from piston.utils import rc
import security
from fluffycentral.repository.models import ServiceProvider, File
from fluffycentral.setti... | Python |
# -*- coding: utf-8 -*-
from django.conf.urls.defaults import *
from piston.authentication import HttpBasicAuthentication
from piston.resource import Resource
from fluffycentral.api.handlers import *
sp_list_handler = Resource(SPListHandler)
sp_list_handler.csrf_exempt = getattr(sp_list_handler.handler, 'csrf_exemp... | Python |
import hmac, base64
from django import forms
from django.conf import settings
class Form(forms.Form):
pass
class ModelForm(forms.ModelForm):
"""
Subclass of `forms.ModelForm` which makes sure
that the initial values are present in the form
data, so you don't have to send all old values
fo... | Python |
"""
Decorator module, see
http://www.phyast.pitt.edu/~micheles/python/documentation.html
for the documentation and below for the licence.
"""
## The basic trick is to generate the source code for the decorated function
## with the right signature and to evaluate it.
## Uncomment the statement 'print >> sys.stderr, fun... | Python |
from utils import rc
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
typemapper = { }
handler_tracker = [ ]
class HandlerMetaClass(type):
"""
Metaclass that keeps a registry of class -> handler
mappings.
"""
def __new__(cls, name, bases, attrs):
new_cls = typ... | Python |
import sys, inspect
from django.http import (HttpResponse, Http404, HttpResponseNotAllowed,
HttpResponseForbidden, HttpResponseServerError)
from django.views.debug import ExceptionReporter
from django.views.decorators.vary import vary_on_headers
from django.conf import settings
from django.core.mail import send_ma... | Python |
from __future__ import generators
import decimal, re, inspect
import copy
try:
# yaml isn't standard with python. It shouldn't be required if it
# isn't used.
import yaml
except ImportError:
yaml = None
# Fallback since `any` isn't in Python <2.5
try:
any
except NameError:
def any(iterable):... | Python |
import urllib
from django.db import models
from django.contrib.auth.models import User
from django.contrib import admin
from django.conf import settings
from django.core.mail import send_mail, mail_admins
from django.template import loader
from managers import TokenManager, ConsumerManager, ResourceManager, KEY_SIZE, ... | Python |
import cgi
import urllib
import time
import random
import urlparse
import hmac
import base64
VERSION = '1.0' # Hi Blaine!
HTTP_METHOD = 'GET'
SIGNATURE_METHOD = 'PLAINTEXT'
# Generic exception class
class OAuthError(RuntimeError):
def get_message(self):
return self._message
def set_message(self, mes... | Python |
from django.db import models
from django.contrib.auth.models import User
KEY_SIZE = 18
SECRET_SIZE = 32
class KeyManager(models.Manager):
'''Add support for random key/secret generation
'''
def generate_random_codes(self):
key = User.objects.make_random_password(length=KEY_SIZE)
secret = U... | Python |
import binascii
import oauth
from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.auth.models import User, AnonymousUser
from django.contrib.auth.decorators import login_required
from django.template import loader
from django.contrib.auth import authenticate
from django.conf import settings
f... | Python |
from django.middleware.http import ConditionalGetMiddleware
from django.middleware.common import CommonMiddleware
def compat_middleware_factory(klass):
"""
Class wrapper that only executes `process_response`
if `streaming` is not set on the `HttpResponse` object.
Django has a bad habbit of looking at t... | Python |
from django.http import HttpResponseNotAllowed, HttpResponseForbidden, HttpResponse, HttpResponseBadRequest
from django.core.urlresolvers import reverse
from django.core.cache import cache
from django import get_version as django_version
from decorator import decorator
from datetime import datetime, timedelta
__versi... | Python |
import inspect, handler
from piston.handler import typemapper
from piston.handler import handler_tracker
from django.core.urlresolvers import get_resolver, get_callable, get_script_prefix
from django.shortcuts import render_to_response
from django.template import RequestContext
def generate_doc(handler_cls):
"""... | Python |
import oauth
from models import Nonce, Token, Consumer
class DataStore(oauth.OAuthDataStore):
"""Layer between Python OAuth and Django database."""
def __init__(self, oauth_request):
self.signature = oauth_request.parameters.get('oauth_signature', None)
self.timestamp = oauth_request.parameter... | Python |
from M2Crypto import RSA
def generateKeys():
keys = RSA.gen_key(2048, 65537)
return keys
def keyToStr(keys):
return keys.as_pem(cipher=None)
def getPublicKey(keys):
pubKey = RSA.new_pub_key(keys.pub())
return pubKey.as_pem(cipher=None)
def encrypt(plaintext,keys):
encText = keys.private_encr... | Python |
#!/usr/bin/python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run ... | Python |
#!/usr/bin/python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run ... | Python |
#!/usr/bin/env python
import os
os.system("python manage.py runserver 127.0.0.1:8002")
| Python |
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template, redirect_to
from django.core.urlresolvers import reverse
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^api/', include('f... | Python |
#!/usr/bin/env python
import os
os.system("python manage.py runserver 127.0.0.1:8002")
| Python |
# Django settings for fluffyprovider project.
import os
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
CENTRAL_REGISTER = '127.0.0.1:8000'
PROVIDER_NAME = 'fluffyshare'
PROVIDER_ADDRESS = '127.0.0.1:8002'
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
... | Python |
from django.db import models
class File(models.Model):
path = models.CharField(max_length=100, unique=True)
author = models.CharField(max_length=100)
description = models.CharField(max_length=500)
def __unicode__(self):
return self.path
| Python |
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
... | Python |
from provider.models import File
from django.contrib import admin
admin.site.register(File)
| Python |
# Create your views here.
from django.http import HttpResponseRedirect, Http404, HttpResponse
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib import auth
from django.contrib.auth.decorators import login_required
from provider.models import File
from fluff... | Python |
# -*- coding: utf-8 -*-
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist
from piston.handler import AnonymousBaseHandler, BaseHandler
from piston.utils import rc
from fluffyshare.settings import MEDIA_ROOT, PROVIDER_NAME
from fluffyshare.provider.models import File
im... | Python |
# -*- coding: utf-8 -*-
from django.conf.urls.defaults import *
from piston.authentication import HttpBasicAuthentication
from piston.resource import Resource
from fluffyshare.api.handlers import *
remote_file_handler = Resource(RemoteFileHandler)
remote_file_handler.csrf_exempt = getattr(remote_file_handler.handle... | Python |
import hmac, base64
from django import forms
from django.conf import settings
class Form(forms.Form):
pass
class ModelForm(forms.ModelForm):
"""
Subclass of `forms.ModelForm` which makes sure
that the initial values are present in the form
data, so you don't have to send all old values
fo... | Python |
"""
Decorator module, see
http://www.phyast.pitt.edu/~micheles/python/documentation.html
for the documentation and below for the licence.
"""
## The basic trick is to generate the source code for the decorated function
## with the right signature and to evaluate it.
## Uncomment the statement 'print >> sys.stderr, fun... | Python |
from utils import rc
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
typemapper = { }
handler_tracker = [ ]
class HandlerMetaClass(type):
"""
Metaclass that keeps a registry of class -> handler
mappings.
"""
def __new__(cls, name, bases, attrs):
new_cls = typ... | Python |
import sys, inspect
from django.http import (HttpResponse, Http404, HttpResponseNotAllowed,
HttpResponseForbidden, HttpResponseServerError)
from django.views.debug import ExceptionReporter
from django.views.decorators.vary import vary_on_headers
from django.conf import settings
from django.core.mail import send_ma... | Python |
from __future__ import generators
import decimal, re, inspect
import copy
try:
# yaml isn't standard with python. It shouldn't be required if it
# isn't used.
import yaml
except ImportError:
yaml = None
# Fallback since `any` isn't in Python <2.5
try:
any
except NameError:
def any(iterable):... | Python |
import urllib
from django.db import models
from django.contrib.auth.models import User
from django.contrib import admin
from django.conf import settings
from django.core.mail import send_mail, mail_admins
from django.template import loader
from managers import TokenManager, ConsumerManager, ResourceManager, KEY_SIZE, ... | Python |
import cgi
import urllib
import time
import random
import urlparse
import hmac
import base64
VERSION = '1.0' # Hi Blaine!
HTTP_METHOD = 'GET'
SIGNATURE_METHOD = 'PLAINTEXT'
# Generic exception class
class OAuthError(RuntimeError):
def get_message(self):
return self._message
def set_message(self, mes... | Python |
from django.db import models
from django.contrib.auth.models import User
KEY_SIZE = 18
SECRET_SIZE = 32
class KeyManager(models.Manager):
'''Add support for random key/secret generation
'''
def generate_random_codes(self):
key = User.objects.make_random_password(length=KEY_SIZE)
secret = U... | Python |
import binascii
import oauth
from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.auth.models import User, AnonymousUser
from django.contrib.auth.decorators import login_required
from django.template import loader
from django.contrib.auth import authenticate
from django.conf import settings
f... | Python |
from django.middleware.http import ConditionalGetMiddleware
from django.middleware.common import CommonMiddleware
def compat_middleware_factory(klass):
"""
Class wrapper that only executes `process_response`
if `streaming` is not set on the `HttpResponse` object.
Django has a bad habbit of looking at t... | Python |
from django.http import HttpResponseNotAllowed, HttpResponseForbidden, HttpResponse, HttpResponseBadRequest
from django.core.urlresolvers import reverse
from django.core.cache import cache
from django import get_version as django_version
from decorator import decorator
from datetime import datetime, timedelta
__versi... | Python |
import inspect, handler
from piston.handler import typemapper
from piston.handler import handler_tracker
from django.core.urlresolvers import get_resolver, get_callable, get_script_prefix
from django.shortcuts import render_to_response
from django.template import RequestContext
def generate_doc(handler_cls):
"""... | Python |
import oauth
from models import Nonce, Token, Consumer
class DataStore(oauth.OAuthDataStore):
"""Layer between Python OAuth and Django database."""
def __init__(self, oauth_request):
self.signature = oauth_request.parameters.get('oauth_signature', None)
self.timestamp = oauth_request.parameter... | Python |
from M2Crypto import RSA
def getPublicKey(keys):
pubKey = RSA.new_pub_key(keys.pub())
return pubKey.as_pem(cipher=None)
def encrypt(plaintext,keys):
encText = keys.private_encrypt(plaintext, 1)
return encText
def decrypt(encText,pubKey):
dec = pubKey.public_decrypt(encText, 1)
return decl
de... | Python |
#!/usr/bin/python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run ... | Python |
#!/usr/bin/python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run ... | Python |
#!/usr/bin/env python
import os
os.system("python manage.py runserver 127.0.0.1:8001")
| Python |
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template, redirect_to
from django.core.urlresolvers import reverse
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^api/', include('f... | Python |
#!/usr/bin/env python
import os
os.system("python manage.py runserver 127.0.0.1:8001")
| Python |
# Django settings for fluffyprovider project.
import os
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
CENTRAL_REGISTER = '127.0.0.1:8000'
PROVIDER_NAME = 'provider1'
PROVIDER_ADDRESS = '127.0.0.1:8001'
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
)
... | Python |
from django.db import models
class File(models.Model):
path = models.CharField(max_length=100, unique=True)
author = models.CharField(max_length=100)
description = models.CharField(max_length=500)
def __unicode__(self):
return self.path
| Python |
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
... | Python |
from provider.models import File
from django.contrib import admin
admin.site.register(File)
| Python |
# Create your views here.
from django.http import HttpResponseRedirect, Http404, HttpResponse
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib import auth
from django.contrib.auth.decorators import login_required
from provider.models import File
from fluff... | Python |
# -*- coding: utf-8 -*-
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist
from piston.handler import AnonymousBaseHandler, BaseHandler
from piston.utils import rc
from fluffyprovider.settings import MEDIA_ROOT, PROVIDER_NAME
from fluffyprovider.provider.models import F... | Python |
# -*- coding: utf-8 -*-
from django.conf.urls.defaults import *
from piston.authentication import HttpBasicAuthentication
from piston.resource import Resource
from fluffyprovider.api.handlers import *
remote_file_handler = Resource(RemoteFileHandler)
remote_file_handler.csrf_exempt = getattr(remote_file_handler.han... | Python |
import hmac, base64
from django import forms
from django.conf import settings
class Form(forms.Form):
pass
class ModelForm(forms.ModelForm):
"""
Subclass of `forms.ModelForm` which makes sure
that the initial values are present in the form
data, so you don't have to send all old values
fo... | Python |
"""
Decorator module, see
http://www.phyast.pitt.edu/~micheles/python/documentation.html
for the documentation and below for the licence.
"""
## The basic trick is to generate the source code for the decorated function
## with the right signature and to evaluate it.
## Uncomment the statement 'print >> sys.stderr, fun... | Python |
from utils import rc
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
typemapper = { }
handler_tracker = [ ]
class HandlerMetaClass(type):
"""
Metaclass that keeps a registry of class -> handler
mappings.
"""
def __new__(cls, name, bases, attrs):
new_cls = typ... | Python |
import sys, inspect
from django.http import (HttpResponse, Http404, HttpResponseNotAllowed,
HttpResponseForbidden, HttpResponseServerError)
from django.views.debug import ExceptionReporter
from django.views.decorators.vary import vary_on_headers
from django.conf import settings
from django.core.mail import send_ma... | Python |
from __future__ import generators
import decimal, re, inspect
import copy
try:
# yaml isn't standard with python. It shouldn't be required if it
# isn't used.
import yaml
except ImportError:
yaml = None
# Fallback since `any` isn't in Python <2.5
try:
any
except NameError:
def any(iterable):... | Python |
Subsets and Splits
SQL Console for ajibawa-2023/Python-Code-Large
Provides a useful breakdown of language distribution in the training data, showing which languages have the most samples and helping identify potential imbalances across different language groups.