Esempio n. 1
0
import logging
import time
import uuid

import numpy as np
import tweepy
from past import autotranslate

autotranslate(['logging_twitter.handler'])
from logging_twitter.handler import TwitterHandler


class TwitterHelper:
    def __init__(self,
                 consumer_key,
                 consumer_secret,
                 access_key,
                 access_secret,
                 debug=False):
        self.consumer_key = consumer_key
        self.consumer_secret = consumer_secret
        self.access_key = access_key
        self.access_secret = access_secret
        self.debug = debug

        if not self.debug:
            auth = tweepy.OAuthHandler(self.consumer_key, self.consumer_secret)
            auth.set_access_token(self.access_key, self.access_secret)
            self.tweet_api = tweepy.API(auth)

    def active_twitter_logger_for(self, logger_name, target_twitter_user):
Esempio n. 2
0
_logger = logging.getLogger("salad")
_logger.addHandler(logging.StreamHandler())
_logger.setLevel(logging.INFO)

__TMPDIR_LOCK = threading.Lock()

if six.PY3:

    if onWindows():
        # create '/tmp' folder if not present
        # required by autotranslate module
        # TODO: remove when https://github.com/PythonCharmers/python-future/issues/295
        # is fixed
        if not os.path.exists("/tmp"):
            with __TMPDIR_LOCK:
                try:
                    os.makedirs("/tmp")
                except OSError as exception:
                    _logger.error(
                        u"Cannot create '\\tmp' folder in root needed for"
                        "'cwltool' Python 3 installation.")
                    exit(1)
    with __TMPDIR_LOCK:
        from past import autotranslate  # type: ignore
        from past.translation import remove_hooks  # type: ignore
        autotranslate(['avro', 'avro.schema'])
        import avro
        import avro.schema  # pylint: disable=no-name-in-module,import-error
        remove_hooks()
#  sentiment.py
#  
#  Copyright 2014 Ben Klein <*****@*****.**>
#  
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#  
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#  
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#  MA 02110-1301, USA.
#  
#  
# This file is to let python3 run these old python2 sentiment analyses
#

#Because this file should appear to hold the functions itself.
#Runs on an older version of python...
from past import autotranslate
autotranslate('sentiment_analysis')
from sentiment_analysis import * 

from basic_sentiment_analysis import *
Esempio n. 4
0
import os
import socket
import threading
import time
import sys

from future import standard_library
from future.utils import PY3
with standard_library.hooks():
    import http.server
    import socketserver

import pytest
import tornado.testing
from past import autotranslate
autotranslate(['pkipplib'])
from pkipplib import pkipplib


TRAVIS_USER = os.getenv('TRAVIS_USER', 'travis')
TRAVIS_BUILD_DIR = os.getenv('TRAVIS_BUILD_DIR')


@pytest.mark.skipif(sys.version_info > (3,),
                    reason='pkipplib is only python2 compatible')
class AsyncSubprocessTestCase(tornado.testing.AsyncTestCase):

    ipptool_path = ('%s/ipptool-20130731/ipptool' % TRAVIS_BUILD_DIR if
                    TRAVIS_BUILD_DIR else '/usr/bin/ipptool')
    config = {'ipptool_path': ipptool_path,
              'login': TRAVIS_USER,
Esempio n. 5
0
:Author: Arthur Goldberg <*****@*****.**>
:Date: 2016-07-12
:Copyright: 2016-2018, Karr Lab
:License: MIT
"""

import sys
import math
import argparse

from matplotlib import pyplot
from matplotlib.backends.backend_pdf import PdfPages

from past import autotranslate
autotranslate(['recordtype'])
from recordtype import recordtype
'''
Steps:
read and parse log
plot parameters:
    line weight
    color, shape, size of symbols
    location legend
x is time, and y is copy number
'''

# A population adjustment event
event_fields = 'time adjustment_type population flux'
Adjustment_event = recordtype('Adjustment_event', event_fields)
Esempio n. 6
0
import os
import sys
import typing

import six

from .utils import onWindows
__author__ = '*****@*****.**'

_logger = logging.getLogger("salad")
_logger.addHandler(logging.StreamHandler())
_logger.setLevel(logging.INFO)

if six.PY3:

    if onWindows:
        # create '/tmp' folder if not present
        # required by autotranslate module
        # TODO: remove when https://github.com/PythonCharmers/python-future/issues/295
        # is fixed
        if not os.path.exists("/tmp"):
            try:
                os.makedirs("/tmp")
            except OSError as exception:
                _logger.error(u"Cannot create '\\tmp' folder in root needed for",
                              "'cwltool' Python 3 installation.")
                exit(1)

    from past import autotranslate  # type: ignore
    autotranslate(['avro', 'avro.schema'])
Esempio n. 7
0

from builtins import object
import os.path

from django.contrib.auth.models import User
from django.db import models
from calisphere.cache_retry import SOLR_select, SOLR_raw, json_loads_url
from django.urls import reverse
from django.utils.encoding import python_2_unicode_compatible
from calisphere.constants import getCollectionData, getRepositoryData
from django.conf import settings
from exhibits.custom_fields import HeroField
from past import autotranslate
autotranslate(['md5s3stash'])
from md5s3stash import md5s3stash

RENDERING_OPTIONS = (
    ('H', 'HTML'),
    ('T', 'Plain Text'),
    ('M', 'Markdown')
)

# class ImageArk(models.Model):
#     hero = models.ImageField(blank=True, verbose_name='Hero Image', upload_to='uploads/')
#     lockup_derivative = models.ImageField(blank=True, verbose_name='Lockup Image', upload_to='uploads/')
#     alternate_lockup_derivative = models.ImageField(blank=True, verbose_name='Alternate Lockup Image', upload_to='uploads/')
#     item_id = models.CharField(blank=True, max_length=200)
#
#     def __str__(self):
#         return self.item_id
Esempio n. 8
0
from __future__ import unicode_literals

from builtins import object
import os.path

from django.contrib.auth.models import User
from django.db import models
from positions.fields import PositionField
from calisphere.cache_retry import SOLR_select, SOLR_raw, json_loads_url
from django.core.urlresolvers import reverse
from django.utils.encoding import python_2_unicode_compatible
from calisphere.constants import getCollectionData, getRepositoryData
from django.conf import settings
from exhibits.custom_fields import HeroField
from past import autotranslate
autotranslate(['md5s3stash'])
from md5s3stash import md5s3stash

RENDERING_OPTIONS = (('H', 'HTML'), ('T', 'Plain Text'), ('M', 'Markdown'))

# class ImageArk(models.Model):
#     hero = models.ImageField(blank=True, verbose_name='Hero Image', upload_to='uploads/')
#     lockup_derivative = models.ImageField(blank=True, verbose_name='Lockup Image', upload_to='uploads/')
#     alternate_lockup_derivative = models.ImageField(blank=True, verbose_name='Alternate Lockup Image', upload_to='uploads/')
#     item_id = models.CharField(blank=True, max_length=200)
#
#     def __str__(self):
#         return self.item_id


class PublishedExhibitManager(models.Manager):
Esempio n. 9
0
# coding=utf-8
import pdb
import pybedtools
from past import autotranslate
autotranslate(['swalign'])
import swalign


def revcomp(seq):
    return "".join(
        [{
            "A": "T",
            "C": "G",
            "G": "C",
            "T": "A",
            "N": "N"
        }[lett] for lett in
         [seq[i] for i in [len(seq) - idx - 1 for idx in range(len(seq))]]])


def getMatchSize(tup):
    if tup[1] == "M":
        return tup[0]
    else:
        return 0


def getAlign(ref_seq, query_seq):
    match = 1
    mismatch = -5
    scoring = swalign.NucleotideScoringMatrix(match, mismatch)
Esempio n. 10
0
from past import autotranslate
autotranslate(['fanficfare.adapters'])
autotranslate(['fanficfare.configurable'])
import fanficfare.adapters
from fanficfare import adapters
from fanficfare.configurable import Configuration


class FFFOverides(object):
    def getNormalStoryURLSite(url):
        # print("getNormalStoryURLSite:%s"%url)
        if not adapters.gerNormalStoryURL.__dummyconfig:
            adapters.getNormalStoryURL.__dummyconfig = Configuration(
                ["test1.com"], "EPUB", lightweight=True)
        # pulling up an adapter is pretty low over-head.  If
        # it fails, it's a bad url.
        try:
            adapter = adapters.getAdapter(
                adapters.getNormalStoryURL.__dummyconfig, url)
            url = adapter.url
            site = adapter.getSiteDomain()
            storyid = adapter.story.getMetadata('storyId')
            del adapter
            return (url, site, storyid)
        except:
            return None
Esempio n. 11
0
# $ pip3 install mypackagename --no-compile   # to ignore SyntaxErrors

from past import autotranslate
autotranslate(['mypackagename'])
import mypackagename
Esempio n. 12
0
#    it under the terms of the GNU General Public License as published by       #
#    the Free Software Foundation; either version 2 of the License, or          #
#    (at your option) any later version.                                        #
#                                                                               #
#    This program is distributed in the hope that it will be useful,            #
#    but WITHOUT ANY WARRANTY; without even the implied warranty of             #
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              #
#    GNU General Public License for more details.                               #
#*******************************************************************************#

# Functions for converting between ascii and gadget format

import sys
import time
from past import autotranslate
autotranslate(['glio'])
import glio
import numpy as np
from astropy.units import solMass, Mpc, m, s


def ascii2gadget(infile, outfile, Lbox, H0, UNITLENGTH_IN_CM):
    '''
    Function to convert a StePS ascii file to Gadget format.
    infile: input StePS ascii file
    outfile: output Gadget file
    '''
    #Setting up the units of distance and time
    UNIT_T = 47.14829951063323  #Unit time in Gy
    UNIT_V = 20.738652969925447  #Unit velocity in km/s
    UNIT_D = 3.0856775814671917e24  #=1Mpc Unit distance in cm (in the StePS code)
Esempio n. 13
0
# http://python-future.org/translation.html
from past import autotranslate
autotranslate(['MouseConnectivityCache'])

# Path to Allen SDK
import sys
sys.path.append('../git3/')

from allensdk.core.mouse_connectivity_cache import MouseConnectivityCache

# The manifest file is a simple JSON file that keeps track of all of
# the data that has already been downloaded onto the hard drives.
# If you supply a relative path, it is assumed to be relative to your
# current working directory.
mcc = MouseConnectivityCache(
    manifest_file='connectivity/mouse_connectivity_manifest.json')

# open up a list of all of the experiments
all_experiments = mcc.get_experiments(dataframe=True)

# take a look at what we know about an experiment with a primary motor injection
#all_experiments.loc[122642490]

# grab the StructureTree instance
structure_tree = mcc.get_structure_tree()

from allensdk.api.queries.ontologies_api import OntologiesApi

oapi = OntologiesApi()

# get the ids of all the structure sets in the tree
Esempio n. 14
0
# Remote Academy LabBox Environment
# Webcam Wrapper

from past import autotranslate
autotranslate(['v4l2'])
import v4l2
import fcntl
import os
import mmap
import time
from io import StringIO

class Webcam:
	def __init__(self):
		self.available = False
		self.cp = None
		self.device = None
		self.fmt = None
		self.reqbuf = None
		self.imagebuffers = []
		
		try:
			fd = os.open('/dev/video0', os.O_RDWR)
			self.device = open(fd, 'wb+', buffering=0)
			
			self.available = True
			self.cp = v4l2.v4l2_capability()
			fcntl.ioctl(self.device, v4l2.VIDIOC_QUERYCAP, self.cp)
		except:
			pass