<commit_before>#!/usr/bin/env python
from setuptools import setup
from os.path import abspath, dirname, join

def readfile(filename):
    path = join(dirname(abspath(__file__)), filename)
    with open(path, 'rt') as filehandle:
        return filehandle.read()

setup(
    name='pip_install_privates',
    version='0.5',
    description='Install pip packages from private repositories without an ssh agent',
    long_description=readfile('README.rst'),
    long_description_content_type='text/x-rst',
    author='Byte Internet',
    author_email='tech@byte.nl',
    license='MIT',
    url='https://github.com/ByteInternet/pip-install-privates',
    packages=['pip_install_privates'],
    install_requires=['pip'],
    entry_points={
        'console_scripts': [
            'pip_install_privates = pip_install_privates.install:install'
        ]
    }
)
<commit_msg>Bump version so we can push to pypi<commit_after>#!/usr/bin/env python
from setuptools import setup
from os.path import abspath, dirname, join

def readfile(filename):
    path = join(dirname(abspath(__file__)), filename)
    with open(path, 'rt') as filehandle:
        return filehandle.read()

setup(
    name='pip_install_privates',
    version='0.5.1',
    description='Install pip packages from private repositories without an ssh agent',
    long_description=readfile('README.rst'),
    long_description_content_type='text/x-rst',
    author='Byte Internet',
    author_email='tech@byte.nl',
    license='MIT',
    url='https://github.com/ByteInternet/pip-install-privates',
    packages=['pip_install_privates'],
    install_requires=['pip'],
    entry_points={
        'console_scripts': [
            'pip_install_privates = pip_install_privates.install:install'
        ]
    }
)
<|endoftext|>


<commit_before>#!/usr/bin/env python

#
# Copyright 2012 BloomReach, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

"""
Super S3 command line tool, setup.py
"""

from setuptools import setup, find_packages

__author__ = "Hardik Vasa"
__copyright__ = "Copyright 2015 @Z Series Innovations"
__license__ = "http://www.apache.org/licenses/LICENSE-2.0"
__version__ = "0.9"
__maintainer__ = __author__
__status__ = "Development"

setup(name='webb',
      version=__version__,
      description='An all-in-one Web Crawler, Web Parser and Web Scrapping library!',
      author=__author__,
      license=__license__,
      url='https://github.com/hardikvasa/webb',
      py_modules=['webb'],
      scripts=['webb.py'], # Added webb.py as script for backward compatibility
    )
<commit_msg>updated setup.py file with new file location<commit_after>#!/usr/bin/env python

#
# Copyright 2012 BloomReach, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

"""
Super S3 command line tool, setup.py
"""

from setuptools import setup, find_packages

__author__ = "Hardik Vasa"
__copyright__ = "Copyright 2015 @Z Series Innovations"
__license__ = "http://www.apache.org/licenses/LICENSE-2.0"
__version__ = "0.9"
__maintainer__ = __author__
__status__ = "Development"

setup(name='webb',
      version=__version__,
      description='An all-in-one Web Crawler, Web Parser and Web Scrapping library!',
      author=__author__,
      license=__license__,
      url='https://github.com/hardikvasa/webb',
      py_modules=['webb'],
      scripts=['webb/webb.py'], # Added webb.py as script for backward compatibility
    )
<|endoftext|>


<commit_before># coding: utf-8

"""
    Kubernetes

    No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)

    OpenAPI spec version: unversioned

    Generated by: https://github.com/swagger-api/swagger-codegen.git

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
"""

import sys
from setuptools import setup, find_packages

NAME = "kubernetes"
VERSION = "0.1.0"

# To install the library, run the following
#
# python setup.py install
#
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["urllib3 >= 1.19", "six >= 1.10", "certifi", "python-dateutil", "pyyaml", "oauth2client"]

setup(
    name=NAME,
    version=VERSION,
    description="Kubernetes python client",
    author_email="",
    url="http://kubernetes.io",
    keywords=["Swagger", "OpenAPI", "Kubernetes"],
    install_requires=REQUIRES,
    packages=['kubernetes', 'kubernetes.client', 'kubernetes.config',
              'kubernetes.watch', 'kubernetes.client.apis',
              'kubernetes.client.models'],
    include_package_data=True,
    long_description="""\
    Python client for talk to a kubernetes cluster.
    """
)
<commit_msg>Update package version<commit_after># Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
from setuptools import setup, find_packages

NAME = "kubernetes"
VERSION = "1.0.0-alpha.1"

# To install the library, run the following
#
# python setup.py install
#
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["urllib3 >= 1.19", "six >= 1.10", "certifi", "python-dateutil", "pyyaml", "oauth2client"]

setup(
    name=NAME,
    version=VERSION,
    description="Kubernetes python client",
    author_email="",
    author="Kubernetes",
    license="Apache License Version 2.0",
    url="https://github.com/kubernetes-incubator/client-python",
    keywords=["Swagger", "OpenAPI", "Kubernetes"],
    install_requires=REQUIRES,
    packages=['kubernetes', 'kubernetes.client', 'kubernetes.config',
              'kubernetes.watch', 'kubernetes.client.apis',
              'kubernetes.client.models'],
    include_package_data=True,
    long_description="""\
    Python client for talk to a kubernetes cluster.
    """
)
<|endoftext|>


<commit_before>#!/usr/bin/env python
# coding: utf-8
import os
import re
import sys

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

def get_version():
    VERSIONFILE = os.path.join('pyhn', '__init__.py')
    initfile_lines = open(VERSIONFILE, 'rt').readlines()
    VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
    for line in initfile_lines:
        mo = re.search(VSRE, line, re.M)
        if mo:
            return mo.group(1)
    raise RuntimeError('Unable to find version string in %s.' % (VERSIONFILE,))

if sys.argv[-1] == 'publish':
    os.system('python setup.py sdist upload')
    sys.exit()

setup(
    name='pyhn',
    version=get_version(),
    description='Hacker News in your terminal',
    long_description=open('README.rst').read(),
    license=open("LICENSE").read(),
    author="Geoffrey Lehée",
    author_email="hello@socketubs.org",
    url='https://github.com/socketubs/pyhn/',
    keywords="python hackernews hn",
    packages=['pyhn'],
    scripts=['scripts/pyhn'],
    install_requires=['urwid', 'beautifulsoup4'],
    classifiers=[
        'Intended Audience :: Developers',
        'Natural Language :: English',
        'License :: OSI Approved :: MIT License',
        'Programming Language :: Python',
        'Programming Language :: Python :: 2',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.4']
)
<commit_msg>Remove beautifulsoup from deps<commit_after>#!/usr/bin/env python
# coding: utf-8
import os
import re
import sys

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

def get_version():
    VERSIONFILE = os.path.join('pyhn', '__init__.py')
    initfile_lines = open(VERSIONFILE, 'rt').readlines()
    VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
    for line in initfile_lines:
        mo = re.search(VSRE, line, re.M)
        if mo:
            return mo.group(1)
    raise RuntimeError('Unable to find version string in %s.' % (VERSIONFILE,))

if sys.argv[-1] == 'publish':
    os.system('python setup.py sdist upload')
    sys.exit()

setup(
    name='pyhn',
    version=get_version(),
    description='Hacker News in your terminal',
    long_description=open('README.rst').read(),
    license=open("LICENSE").read(),
    author="Geoffrey Lehée",
    author_email="hello@socketubs.org",
    url='https://github.com/socketubs/pyhn/',
    keywords="python hackernews hn",
    packages=['pyhn'],
    scripts=['scripts/pyhn'],
    install_requires=['urwid'],
    classifiers=[
        'Intended Audience :: Developers',
        'Natural Language :: English',
        'License :: OSI Approved :: MIT License',
        'Programming Language :: Python',
        'Programming Language :: Python :: 2',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.4']
)
<|endoftext|>


<commit_before>#!/usr/bin/python

from setuptools import setup, find_packages

import openaps
def readme():
    with open("README.md") as f:
        return f.read()

setup(name='openaps',
    version=openaps.__version__, # http://semver.org/
    description='DIY Open Source Artificial Pancreas System.',
    long_description=readme(),
    author="OpenAPS",
    author_email="bewest+openaps@gmail.com",
    # url="https://github.com/openaps/openaps",
    url="https://openaps.org/",
    packages=find_packages( ),
    include_package_data = True,
    install_requires = [
      'pyserial', 'python-dateutil', 'argcomplete',
      'gitpython',
      'decocare > 0.0.13', 'dexcom_reader > 0.0.5'
    ],
    dependency_links = [
      'http://github.com/compbrain/dexcom_reader/tarball/master#egg=dexcom_reader-master',
      'https://github.com/bewest/dexcom_reader/tarball/master#egg=dexcom_reader-0.0.7-dev-1',
      'https://github.com/bewest/decoding-carelink/tarball/master#egg=decocare-master',
      'https://github.com/bewest/decoding-carelink/tarball/dev#egg=decocare-0.0.16-dev-1',
    ],
    scripts = [
      'bin/openaps',
      'bin/openaps-device',
      'bin/openaps-use',
      'bin/openaps-report',
      'bin/openaps-vendor',
      'bin/openaps-alias',
      'bin/git-openaps-init',
      'bin/openaps-install-udev-rules',
    ],
    classifiers = [
        'Development Status :: 3 - Alpha',
        'Intended Audience :: Developers',
        'Intended Audience :: Science/Research',
        'Programming Language :: Python',
        'Topic :: Scientific/Engineering',
        'Topic :: Software Development :: Libraries'
    ],
    zip_safe=False,
)

#####
# EOF
<commit_msg>bump decocare version dependency specs<commit_after>#!/usr/bin/python

from setuptools import setup, find_packages

import openaps
def readme():
    with open("README.md") as f:
        return f.read()

setup(name='openaps',
    version=openaps.__version__, # http://semver.org/
    description='DIY Open Source Artificial Pancreas System.',
    long_description=readme(),
    author="OpenAPS",
    author_email="bewest+openaps@gmail.com",
    # url="https://github.com/openaps/openaps",
    url="https://openaps.org/",
    packages=find_packages( ),
    include_package_data = True,
    install_requires = [
      'pyserial', 'python-dateutil', 'argcomplete',
      'gitpython',
      'decocare > 0.0.15', 'dexcom_reader > 0.0.5'
    ],
    dependency_links = [
      'http://github.com/compbrain/dexcom_reader/tarball/master#egg=dexcom_reader-master',
      'https://github.com/bewest/dexcom_reader/tarball/master#egg=dexcom_reader-0.0.7-dev-1',
      'https://github.com/bewest/decoding-carelink/tarball/master#egg=decocare-master',
      'https://github.com/bewest/decoding-carelink/tarball/dev#egg=decocare-0.0.17-dev-1',
    ],
    scripts = [
      'bin/openaps',
      'bin/openaps-device',
      'bin/openaps-use',
      'bin/openaps-report',
      'bin/openaps-vendor',
      'bin/openaps-alias',
      'bin/git-openaps-init',
      'bin/openaps-install-udev-rules',
    ],
    classifiers = [
        'Development Status :: 3 - Alpha',
        'Intended Audience :: Developers',
        'Intended Audience :: Science/Research',
        'Programming Language :: Python',
        'Topic :: Scientific/Engineering',
        'Topic :: Software Development :: Libraries'
    ],
    zip_safe=False,
)

#####
# EOF
<|endoftext|>


<commit_before>"""Setuptools file for a MultiMarkdown Python wrapper."""
from codecs import open
from os import path
from distutils.core import setup
from distutils.util import get_platform
from setuptools import find_packages, Command, Distribution
from pymmd import build_mmd
import sys
import glob

here = path.abspath(path.dirname(__file__))

class BuildMMDCommand(Command):
    """Build MMD to include in package."""
    description = "Downloads and builds MultiMarkdown shared library and adds it to the distribution"
    user_options = []
    def initialize_options(self):
        pass
    def finalize_options(self):
        pass
    def run(self):
        build_mmd(path.join(here, 'pymmd', 'files'))

class BinaryDistribution(Distribution):
    """Forcing distribution to not be considered pure"""
    def is_pure(self):
        return False

if "download_mmd" in sys.argv and "bdist_wheel" in sys.argv:
    sys.argv.append('--plat-name')
    sys.argv.append(get_platform())

with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
    long_description = f.read()

setup(
    name='pymmd',
    version='0.3.0',
    description='Python wrapper for the MultiMarkdown library.',
    long_description=long_description,
    license='MIT',
    author='Jason Ziglar',
    author_email='jasedit@gmail.com',
    url="https://github.com/jasedit/pymmd",
    classifiers=[
        'Development Status :: 3 - Alpha',
        'Intended Audience :: Developers',
        'Topic :: Text Processing :: Markup',
        'Topic :: Text Processing :: Filters',
        'Topic :: Software Development :: Libraries :: Python Modules',
        'License :: OSI Approved :: MIT License',
        'Programming Language :: Python :: 2',
        'Programming Language :: Python :: 3'
    ],
    packages=find_packages(),
    package_data={'pymmd': ['files/*']},
    cmdclass={'download_mmd': BuildMMDCommand},
    distclass=BinaryDistribution
    )
<commit_msg>Increment to 0.4.0 to release convert_from function<commit_after>"""Setuptools file for a MultiMarkdown Python wrapper."""
from codecs import open
from os import path
from distutils.core import setup
from distutils.util import get_platform
from setuptools import find_packages, Command, Distribution
from pymmd import build_mmd
import sys
import glob

here = path.abspath(path.dirname(__file__))

class BuildMMDCommand(Command):
    """Build MMD to include in package."""
    description = "Downloads and builds MultiMarkdown shared library and adds it to the distribution"
    user_options = []
    def initialize_options(self):
        pass
    def finalize_options(self):
        pass
    def run(self):
        build_mmd(path.join(here, 'pymmd', 'files'))

class BinaryDistribution(Distribution):
    """Forcing distribution to not be considered pure"""
    def is_pure(self):
        return False

if "download_mmd" in sys.argv and "bdist_wheel" in sys.argv:
    sys.argv.append('--plat-name')
    sys.argv.append(get_platform())

with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
    long_description = f.read()

setup(
    name='pymmd',
    version='0.4.0',
    description='Python wrapper for the MultiMarkdown library.',
    long_description=long_description,
    license='MIT',
    author='Jason Ziglar',
    author_email='jasedit@gmail.com',
    url="https://github.com/jasedit/pymmd",
    classifiers=[
        'Development Status :: 3 - Alpha',
        'Intended Audience :: Developers',
        'Topic :: Text Processing :: Markup',
        'Topic :: Text Processing :: Filters',
        'Topic :: Software Development :: Libraries :: Python Modules',
        'License :: OSI Approved :: MIT License',
        'Programming Language :: Python :: 2',
        'Programming Language :: Python :: 3'
    ],
    packages=find_packages(),
    package_data={'pymmd': ['files/*']},
    cmdclass={'download_mmd': BuildMMDCommand},
    distclass=BinaryDistribution
    )
<|endoftext|>


<commit_before>import logging
log = logging.getLogger(__name__)

from django.shortcuts import (
    render,
    redirect,
)

from django.db import IntegrityError
from django.contrib import messages

from apps.api.models import (
    Group,
    Song,
    Person,
    Collection,
    Duplicate,
    GroupF,
    SongF,
)

def home(request):
    return render(
        request,
        'home.html',
    )

def collections(request):
    collections = Collection.objects.exclude(is_flag=True).order_by('id')
    return render(
        request,
        'collections.html',
        {'collections': collections},
    )

def collection(request, id):
    collection = Collection.objects.get(id=id)
    dups = []
    if collection.primitive.name == 'Group':
        for d in collection.duplicates.all():
            g = Group.objects.get(id=d.source_id)
            dups.append(g)
    elif collection.primitive.name == 'Song':
        for d in collection.duplicates.all():
            s = Song.objects.get(id=d.source_id)
            dups.append(s)
    elif collection.primitive.name == 'Person':
        for d in collection.duplicates.all():
            p = Person.objects.get(id=d.source_id)
            dups.append(p)
    return render(
        request,
        'collection.html',
        {'collection': collection, 'dups': dups},
    )

def merge(request, id):
    keep = Duplicate.objects.get(source_id=id)
    collection = keep.collection
    if collection.primitive.name == 'Group':
        parent = Group.objects.get(id=keep.source_id)
    elif collection.primitive.name == 'Song':
        parent = Song.objects.get(id=keep.source_id)
    elif collection.primitive.name == 'Person':
        parent = Person.objects.get(id=keep.source_id)
    else:
        raise RuntimeError("No primitive selected.")
    orphans = collection.duplicates.exclude(source_id=id)
    for orphan in orphans:
        if collection.primitive.name == 'Group':
            drop = Group.objects.get(id=orphan.source_id)
            for contestant in drop.contestants.all():
                contestant.group = parent
                contestant.save()
            drop.delete()
        elif collection.primitive.name == 'Song':
            drop = Song.objects.get(id=orphan.source_id)
            for chart in drop.charts.all():
                chart.songs.add(parent)
                chart.songs.remove(drop)
            drop.delete()
        elif collection.primitive.name == 'Person':
            drop = Person.objects.get(id=orphan.source_id)
            for director in drop.choruses.all():
                director.person = parent
                director.save()
            for singer in drop.quartets.all():
                singer.person = parent
                singer.save()
            for arrangement in drop.arrangements.all():
                arrangement.person = parent
                arrangement.save()
            drop.delete()
        else:
            raise RuntimeError("How did i get here?")
    try:
        r = redirect('website:collection', collection.get_next().id)
    except AttributeError:
        r = redirect('website:collections')
    collection.delete()
    return r

def skip(request, id):
    collection = Collection.objects.get(id=id)
    try:
        r = redirect('website:collection', collection.get_next().id)
    except AttributeError:
        r = redirect('website:collections')
    collection.delete()
    return r

def flag(request, id):
    collection = Collection.objects.get(id=id)
    try:
        r = redirect('website:collection', collection.get_next().id)
    except AttributeError:
        r = redirect('website:collections')
    collection.is_flag = True
    collection.save()
    return r

def merge_group(request, parent, child):
    parent = Group.objects.get(id=parent)
    child = Group.objects.get(id=child)
    if parent.kind == 1:
        r = redirect('website:quartets')
    else:
        r = redirect('website:choruses')
    contestants = child.contestants.all()
    if not contestants:
        child.delete()
        messages.warning(
            request,
            "Merged {0} into {1}.".format(child, parent)
        )
        return r
    # move related records
    for contestant in contestants:
        contestant.group = parent
        try:
            contestant.save()
        except IntegrityError:
            raise RuntimeError(
                "Contestant {0} already exists.  Merge manually".format(contestant)
            )
    # remove redundant group
    try:
        child.delete()
    except Exception as e:
        raise RuntimeError("Error deleting old group: {0}".format(e))
    duplicates = GroupF.objects.filter(parent=parent)
    duplicates.delete()
    messages.success(
        request,
        "Merged {0} into {1}.".format(child, parent)
    )
    return r

def remove_group(request, parent):
    duplicates = GroupF.objects.filter(parent__id=parent)
    duplicates.delete()
    messages.danger(
        request,
        "Removed {0} from duplicates.".format(parent)
    )
    return redirect('website:groups')

def merge_song(request, parent, child):
    parent = Song.objects.get(id=parent)
    child = Song.objects.get(id=child)
    charts = child.charts.all()
    if not charts:
        child.delete()
        messages.warning(
            request,
            "Merged {0} into {1}.".format(child, parent)
        )
        return redirect('website:songs')
    # move related records
    for chart in charts:
        chart.song = parent
        try:
            chart.save()
        except IntegrityError:
            raise RuntimeError(
                "Chart {0} already exists.  Merge manually".format(chart)
            )
    # remove redundant group
    try:
        child.delete()
    except Exception as e:
        raise RuntimeError("Error deleting old song: {0}".format(e))
    duplicates = SongF.objects.filter(parent=parent)
    duplicates.delete()
    messages.success(
        request,
        "Merged {0} into {1}.".format(child, parent)
    )
    return redirect('website:songs')

def remove_song(request, parent):
    duplicates = SongF.objects.filter(parent__id=parent)
    duplicates.delete()
    messages.danger(
        request,
        "Removed {0} from duplicates.".format(parent)
    )
    return redirect('website:songs')

def choruses(request):
    groups = Group.objects.filter(
        group_duplicates__isnull=False,
    ).filter(kind=2).distinct().order_by('name')
    return render(
        request,
        'groups.html',
        {'groups': groups},
    )

def quartets(request):
    groups = Group.objects.filter(
        group_duplicates__isnull=False,
    ).filter(kind=1).distinct().order_by('name')
    return render(
        request,
        'groups.html',
        {'groups': groups},
    )

def songs(request):
    songs = Song.objects.filter(
        song_duplicates__isnull=False,
    ).distinct().order_by('name')
    return render(
        request,
        'songs.html',
        {'songs': songs},
    )

def persons(request):
    persons = Person.objects.filter(
        person_duplicates__isnull=False,
    ).distinct().order_by('name')[:100]
    return render(
        request,
        'persons.html',
        {'persons': persons},
    )
<commit_msg>Messages method fix<commit_after>import logging
log = logging.getLogger(__name__)

from django.shortcuts import (
    render,
    redirect,
)

from django.db import IntegrityError
from django.contrib import messages

from apps.api.models import (
    Group,
    Song,
    Person,
    Collection,
    Duplicate,
    GroupF,
    SongF,
)

def home(request):
    return render(
        request,
        'home.html',
    )

def collections(request):
    collections = Collection.objects.exclude(is_flag=True).order_by('id')
    return render(
        request,
        'collections.html',
        {'collections': collections},
    )

def collection(request, id):
    collection = Collection.objects.get(id=id)
    dups = []
    if collection.primitive.name == 'Group':
        for d in collection.duplicates.all():
            g = Group.objects.get(id=d.source_id)
            dups.append(g)
    elif collection.primitive.name == 'Song':
        for d in collection.duplicates.all():
            s = Song.objects.get(id=d.source_id)
            dups.append(s)
    elif collection.primitive.name == 'Person':
        for d in collection.duplicates.all():
            p = Person.objects.get(id=d.source_id)
            dups.append(p)
    return render(
        request,
        'collection.html',
        {'collection': collection, 'dups': dups},
    )

def merge(request, id):
    keep = Duplicate.objects.get(source_id=id)
    collection = keep.collection
    if collection.primitive.name == 'Group':
        parent = Group.objects.get(id=keep.source_id)
    elif collection.primitive.name == 'Song':
        parent = Song.objects.get(id=keep.source_id)
    elif collection.primitive.name == 'Person':
        parent = Person.objects.get(id=keep.source_id)
    else:
        raise RuntimeError("No primitive selected.")
    orphans = collection.duplicates.exclude(source_id=id)
    for orphan in orphans:
        if collection.primitive.name == 'Group':
            drop = Group.objects.get(id=orphan.source_id)
            for contestant in drop.contestants.all():
                contestant.group = parent
                contestant.save()
            drop.delete()
        elif collection.primitive.name == 'Song':
            drop = Song.objects.get(id=orphan.source_id)
            for chart in drop.charts.all():
                chart.songs.add(parent)
                chart.songs.remove(drop)
            drop.delete()
        elif collection.primitive.name == 'Person':
            drop = Person.objects.get(id=orphan.source_id)
            for director in drop.choruses.all():
                director.person = parent
                director.save()
            for singer in drop.quartets.all():
                singer.person = parent
                singer.save()
            for arrangement in drop.arrangements.all():
                arrangement.person = parent
                arrangement.save()
            drop.delete()
        else:
            raise RuntimeError("How did i get here?")
    try:
        r = redirect('website:collection', collection.get_next().id)
    except AttributeError:
        r = redirect('website:collections')
    collection.delete()
    return r

def skip(request, id):
    collection = Collection.objects.get(id=id)
    try:
        r = redirect('website:collection', collection.get_next().id)
    except AttributeError:
        r = redirect('website:collections')
    collection.delete()
    return r

def flag(request, id):
    collection = Collection.objects.get(id=id)
    try:
        r = redirect('website:collection', collection.get_next().id)
    except AttributeError:
        r = redirect('website:collections')
    collection.is_flag = True
    collection.save()
    return r

def merge_group(request, parent, child):
    parent = Group.objects.get(id=parent)
    child = Group.objects.get(id=child)
    if parent.kind == 1:
        r = redirect('website:quartets')
    else:
        r = redirect('website:choruses')
    contestants = child.contestants.all()
    if not contestants:
        child.delete()
        messages.warning(
            request,
            "Merged {0} into {1}.".format(child, parent)
        )
        return r
    # move related records
    for contestant in contestants:
        contestant.group = parent
        try:
            contestant.save()
        except IntegrityError:
            raise RuntimeError(
                "Contestant {0} already exists.  Merge manually".format(contestant)
            )
    # remove redundant group
    try:
        child.delete()
    except Exception as e:
        raise RuntimeError("Error deleting old group: {0}".format(e))
    duplicates = GroupF.objects.filter(parent=parent)
    duplicates.delete()
    messages.success(
        request,
        "Merged {0} into {1}.".format(child, parent)
    )
    return r

def remove_group(request, parent):
    duplicates = GroupF.objects.filter(parent__id=parent)
    duplicates.delete()
    messages.error(
        request,
        "Removed {0} from duplicates.".format(parent)
    )
    return redirect('website:groups')

def merge_song(request, parent, child):
    parent = Song.objects.get(id=parent)
    child = Song.objects.get(id=child)
    charts = child.charts.all()
    if not charts:
        child.delete()
        messages.warning(
            request,
            "Merged {0} into {1}.".format(child, parent)
        )
        return redirect('website:songs')
    # move related records
    for chart in charts:
        chart.song = parent
        try:
            chart.save()
        except IntegrityError:
            raise RuntimeError(
                "Chart {0} already exists.  Merge manually".format(chart)
            )
    # remove redundant group
    try:
        child.delete()
    except Exception as e:
        raise RuntimeError("Error deleting old song: {0}".format(e))
    duplicates = SongF.objects.filter(parent=parent)
    duplicates.delete()
    messages.success(
        request,
        "Merged {0} into {1}.".format(child, parent)
    )
    return redirect('website:songs')

def remove_song(request, parent):
    duplicates = SongF.objects.filter(parent__id=parent)
    duplicates.delete()
    messages.error(
        request,
        "Removed {0} from duplicates.".format(parent)
    )
    return redirect('website:songs')

def choruses(request):
    groups = Group.objects.filter(
        group_duplicates__isnull=False,
    ).filter(kind=2).distinct().order_by('name')
    return render(
        request,
        'groups.html',
        {'groups': groups},
    )

def quartets(request):
    groups = Group.objects.filter(
        group_duplicates__isnull=False,
    ).filter(kind=1).distinct().order_by('name')
    return render(
        request,
        'groups.html',
        {'groups': groups},
    )

def songs(request):
    songs = Song.objects.filter(
        song_duplicates__isnull=False,
    ).distinct().order_by('name')
    return render(
        request,
        'songs.html',
        {'songs': songs},
    )

def persons(request):
    persons = Person.objects.filter(
        person_duplicates__isnull=False,
    ).distinct().order_by('name')[:100]
    return render(
        request,
        'persons.html',
        {'persons': persons},
    )
<|endoftext|>


<commit_before>from setuptools import setup

VERSION = "0.1.1"

setup(
    name="pusherclient",
    version=VERSION,
    description="Pusher websocket client for python",
    author="Erik Kulyk",
    author_email="e.kulyk@gmail.com",
    license="",
    url="",
    requires=["websocket-client"],
    packages=["pusherclient"],
)
<commit_msg>Update setup.py to use install_requires keyword.<commit_after>from setuptools import setup

VERSION = "0.1.1"

setup(
    name="pusherclient",
    version=VERSION,
    description="Pusher websocket client for python",
    author="Erik Kulyk",
    author_email="e.kulyk@gmail.com",
    license="",
    url="",
    install_requires=["websocket-client"],
    packages=["pusherclient"],
)
<|endoftext|>


<commit_before>#!/usr/bin/env python
import glob

from setuptools import setup, find_packages
from pip.req import parse_requirements

try:
    with open("requirements.txt", "r") as f:
        install_requires = [x.strip() for x in f.readlines()]
except IOError:
    install_requires = []

setup(name='bcbio_monitor',
      version='0.1',
      description="bcbio-monitor is an extension of bcbio-nextgen to visualize its progress",
      author='Guillermo Carrasco',
      author_email='guille.ch.88@gmail.com',
      url='https://github.com/guillermo-carrasco/bcbio-nextgen-monitor',
      packages=find_packages(),
      include_package_data=True,
      keywords=['bcbio', 'bcbio-nextgen', 'bioinformatics', 'genomics'],
      zip_safe=True,
      entry_points={
        'console_scripts': [
            'bcbio_monitor = bcbio_monitor:main',
        ],
    },
      install_requires=install_requires
)
<commit_msg>Fixes #24<commit_after>#!/usr/bin/env python
import glob

from setuptools import setup, find_packages

try:
    with open("requirements.txt", "r") as f:
        install_requires = [x.strip() for x in f.readlines()]
except IOError:
    install_requires = []

setup(name='bcbio_monitor',
      # For versioning: http://semver.org/
      version='0.1.1',
      description="bcbio-monitor is an extension of bcbio-nextgen to visualize its progress",
      author='Guillermo Carrasco',
      author_email='guille.ch.88@gmail.com',
      url='https://github.com/guillermo-carrasco/bcbio-nextgen-monitor',
      packages=find_packages(),
      include_package_data=True,
      keywords=['bcbio', 'bcbio-nextgen', 'bioinformatics', 'genomics'],
      zip_safe=True,
      entry_points={
        'console_scripts': [
            'bcbio_monitor = bcbio_monitor:main',
        ],
    },
      install_requires=install_requires
)
<|endoftext|>


<commit_before>"""
py3status
"""

import os
from setuptools import find_packages, setup

# Utility function to read the README file.
# Used for the long_description.  It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def read(fname):
    return open(os.path.join(os.path.dirname(__file__), fname)).read()

setup(
    name='py3status',
    version='2.9',
    author='Ultrabug',
    author_email='ultrabug@ultrabug.net',
    description='py3status is an extensible i3status wrapper written in python',
    long_description=read('README.rst'),
    url='https://github.com/ultrabug/py3status',
    download_url='https://github.com/ultrabug/py3status/tags',
    license='BSD',
    platforms='any',
    packages=find_packages(),
    include_package_data=True,
    install_requires=[],
    entry_points={
        'console_scripts': [
            'py3status = py3status:main',
            ]
        },
    classifiers=[
        'License :: OSI Approved :: BSD License',
        'Operating System :: POSIX :: Linux',
        'Programming Language :: Python',
        'Programming Language :: Python :: 2.6',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.2',
        'Programming Language :: Python :: 3.3',
        'Programming Language :: Python :: 3.4',
        'Programming Language :: Python :: 3.5',
        'Topic :: Software Development :: Libraries :: Python Modules',
        ],
    )
<commit_msg>this is 3.0 release candidate fixes #290<commit_after>"""
py3status
"""

import os
from setuptools import find_packages, setup

# Utility function to read the README file.
# Used for the long_description.  It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def read(fname):
    return open(os.path.join(os.path.dirname(__file__), fname)).read()

setup(
    name='py3status',
    version='3.0_rc',
    author='Ultrabug',
    author_email='ultrabug@ultrabug.net',
    description='py3status is an extensible i3status wrapper written in python',
    long_description=read('README.rst'),
    url='https://github.com/ultrabug/py3status',
    download_url='https://github.com/ultrabug/py3status/tags',
    license='BSD',
    platforms='any',
    packages=find_packages(),
    include_package_data=True,
    install_requires=[],
    entry_points={
        'console_scripts': [
            'py3status = py3status:main',
            ]
        },
    classifiers=[
        'License :: OSI Approved :: BSD License',
        'Operating System :: POSIX :: Linux',
        'Programming Language :: Python',
        'Programming Language :: Python :: 2.6',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.2',
        'Programming Language :: Python :: 3.3',
        'Programming Language :: Python :: 3.4',
        'Programming Language :: Python :: 3.5',
        'Topic :: Software Development :: Libraries :: Python Modules',
        ],
    )
<|endoftext|>


<commit_before>#!/usr/bin/env python
#
# Copyright 2017 team1@course_bigdata, Saint Joseph's University
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

"""This file includes variables for the values that configurable and changing.
Developers shall keep their own versions locally for their own development environments.
The values of the variables will be set to different values for the runtime environment.
"""

# The google project id - Place your project id here
GOOG_PROJECT_ID = r''
# The google service credentials.
GOOG_CREDENTIALS_FILE_PATH = r''
# The dataset name
GOOG_DATASET_NAME = r''

# Query related
MAX_RESULT_COUNT = 20
<commit_msg>a formal cust_settings<commit_after>#!/usr/bin/env python
#
# Copyright 2017 team1@course_bigdata, Saint Joseph's University
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

"""This file includes variables for the values that configurable and changing.
Developers shall keep their own versions locally for their own development environments.
The values of the variables will be set to different values for the runtime environment.
"""

# The google project id - Place your project id here
GOOG_PROJECT_ID = r'<project id>'
# The google service credentials.
GOOG_CREDENTIALS_FILE_PATH = r'<service account secret file path>'
# The dataset name
GOOG_DATASET_NAME = r'<project data set name>'

# Query related
MAX_RESULT_COUNT = 500
# Google API timeout
GOOG_API_FETCH_TIMEOUT = 120
<|endoftext|>


<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import subprocess
import zipfile

from tomato import __version__

try:
    import ConfigParser  # python 2
except ImportError:
    import configparser as ConfigParser  # python 3
try:
    from urllib2 import urlopen  # python 2
except ImportError:
    from urllib.request import urlopen  # python 3

try:
    from setuptools import setup
    from setuptools import find_packages
    from setuptools.command.install import install as _install
except ImportError:
    from distutils.core import setup
    from setuptools import find_packages  # no replacement in distutils
    from distutils.command.install import install as _install

class CustomInstall(_install):
    def run(self):
        # install requirements.txt
        subprocess.call(["pip install -r requirements.txt"], shell=True)

        # download the binaries
        self.execute(self._setup_binaries, (),
                     msg="Downloaded the binaries from tomato_binaries.")

        # install tomato
        _install.run(self)

    @classmethod
    def _setup_binaries(cls):
        """
        Downloads the binaries compiled by MATLAB Runtime Compiler from
        tomato_binaries
        """
        bin_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                  'tomato', 'bin')

        # find os, linux or macosx
        sys_os = cls._get_os()

        # read configuration file
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   'tomato', 'config', 'bin.cfg')

        config = ConfigParser.ConfigParser()
        config.optionxform = str
        config.read(config_file)

        # Download binaries
        for bin_name, bin_url in config.items(sys_os):
            bin_path = os.path.join(bin_folder, bin_name)
            cls._download_binary(bin_path, bin_url, sys_os)

    @staticmethod
    def _get_os():
        process_out = subprocess.check_output(['uname']).lower().decode(
            "utf-8")

        if any(ss in process_out for ss in ['darwin', 'macosx']):
            sys_os = 'macosx'
        elif 'linux' in process_out:
            sys_os = 'linux'
        else:
            raise OSError("Unsupported OS.")

        return sys_os

    @staticmethod
    def _download_binary(fpath, bin_url, sys_os):
        print(u"  Downloading binary: {0:s}".format(bin_url))
        response = urlopen(bin_url)
        if fpath.endswith('.zip'):  # binary in zip
            from six import BytesIO

            with zipfile.ZipFile(BytesIO(response.read())) as z:
                z.extractall(os.path.dirname(fpath))
            if sys_os == 'macosx':  # mac executables are actually in an app
                fpath = os.path.splitext(fpath)[0] + '.app'
            else:  # remove the zip extension
                fpath = os.path.splitext(fpath)[0]
        else:  # binary itself
            with open(fpath, 'wb') as fp:
                fp.write(response.read())

        # make the binary executable
        subprocess.call(["chmod -R +x " + fpath], shell=True)
        print(fpath)

setup(name='tomato',
      version=__version__,
      author='Sertan Senturk',
      author_email='contact AT sertansenturk DOT com',
      maintainer='Sertan Senturk',
      maintainer_email='contact AT sertansenturk DOT com',
      url='http://sertansenturk.com',
      description='Turkish-Ottoman Makam (M)usic Analysis TOolbox',
      long_description="""\
Turkish-Ottoman Makam (M)usic Analysis TOolbox
----------------------------------------------
tomato is a comprehensive and easy-to-use toolbox for the analysis of audio
recordings and music scores of Turkish-Ottoman makam music.
The aim of the toolbox is to allow the user to easily analyze large-scale
audio recording and music score collections of Turkish-Ottoman makam music,
using the state of the art methodologies specifically designed for the
necessities of this tradition. The analysis results can then be further used
for several tasks such as automatic content description, music
discovery/recommendation and musicological analysis.
      """,
      download_url='https://github.com/sertansenturk/tomato/releases/tag/'
                   'v{0:s}'.format(__version__),
      classifiers=[
          'Development Status :: 4 - Beta',
          'Environment :: Console',
          'Intended Audience :: Science/Research',
          'Intended Audience :: Information Technology',
          'License :: OSI Approved :: GNU Affero General Public License v3 or '
          'later (AGPLv3+)',
          'Natural Language :: English'
          'Operating System :: MacOS :: MacOS X',
          'Operating System :: POSIX :: Linux',
          'Programming Language :: Python :: 3',
          'Programming Language :: Python :: 3.5',
          'Programming Language :: Python :: 3.6',
          'Programming Language :: Python :: 3.7',
          'Topic :: Multimedia :: Sound/Audio :: Analysis',
          'Topic :: Scientific/Engineering :: Information Analysis',
          ],
      platforms='Linux, MacOS X',
      license='agpl 3.0',
      keywords=(
          "music-scores analysis tomato audio-recordings lilypond tonic "
          "makam-music score music-information-retrieval "
          "computational-analysis"),
      packages=find_packages(exclude=['contrib', 'docs', 'tests']),
      include_package_data=True,
      python_requires='>=3.5, <3.8',
      install_requires=[
          "numpy>=1.9.0"  # numerical operations
          "scipy>=0.17.0",  # temporary mat file saving for MCR binary inputs
          "pandas>=0.18.0",  # tabular data processing
          "matplotlib>=1.5.1",  # plotting
          "json_tricks>=3.12.1",  # saving json files with classes and numpy
          "eyeD3>=0.7.5",  # reading metadata embedded in the audio recordings
          "six>=1.10.0",  # Python 2*3 support
          "future>=0.15.2",  # Python 2*3 support
          "python-Levenshtein>=0.12.0",  # semiotic structure labeling
          "networkx>=1.11"  # semiotic structure labeling clique computation
          "lxml>=3.6.0",  # musicxml conversion
          "musicbrainzngs>=0.6"  # metadata crawling from musicbrainz
          "essentia>=2.1b5;platform_system=='Linux'"  # audio signal processing
          ],
      cmdclass={'install': CustomInstall},
      )
<commit_msg>setup.py specifies where the binaries are downloaded<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import subprocess
import zipfile

from tomato import __version__

try:
    import ConfigParser  # python 2
except ImportError:
    import configparser as ConfigParser  # python 3
try:
    from urllib2 import urlopen  # python 2
except ImportError:
    from urllib.request import urlopen  # python 3

try:
    from setuptools import setup
    from setuptools import find_packages
    from setuptools.command.install import install as _install
except ImportError:
    from distutils.core import setup
    from setuptools import find_packages  # no replacement in distutils
    from distutils.command.install import install as _install

class CustomInstall(_install):
    def run(self):
        # install requirements.txt
        subprocess.call(["pip install -r requirements.txt"], shell=True)

        # download the binaries
        self.execute(self._setup_binaries, (),
                     msg="Downloaded the binaries from tomato_binaries.")

        # install tomato
        _install.run(self)

    @classmethod
    def _setup_binaries(cls):
        """
        Downloads the binaries compiled by MATLAB Runtime Compiler from
        tomato_binaries
        """
        bin_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                  'tomato', 'bin')

        # find os, linux or macosx
        sys_os = cls._get_os()

        # read configuration file
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   'tomato', 'config', 'bin.cfg')

        config = ConfigParser.ConfigParser()
        config.optionxform = str
        config.read(config_file)

        # Download binaries
        for bin_name, bin_url in config.items(sys_os):
            bin_path = os.path.join(bin_folder, bin_name)
            cls._download_binary(bin_path, bin_url, sys_os)

    @staticmethod
    def _get_os():
        process_out = subprocess.check_output(['uname']).lower().decode(
            "utf-8")

        if any(ss in process_out for ss in ['darwin', 'macosx']):
            sys_os = 'macosx'
        elif 'linux' in process_out:
            sys_os = 'linux'
        else:
            raise OSError("Unsupported OS.")

        return sys_os

    @staticmethod
    def _download_binary(fpath, bin_url, sys_os):
        response = urlopen(bin_url)
        if fpath.endswith('.zip'):  # binary in zip
            from six import BytesIO

            with zipfile.ZipFile(BytesIO(response.read())) as z:
                z.extractall(os.path.dirname(fpath))
            if sys_os == 'macosx':  # mac executables are actually in an app
                fpath = os.path.splitext(fpath)[0] + '.app'
            else:  # remove the zip extension
                fpath = os.path.splitext(fpath)[0]
        else:  # binary itself
            with open(fpath, 'wb') as fp:
                fp.write(response.read())

        # make the binary executable
        subprocess.call(["chmod -R +x " + fpath], shell=True)
        print(f"  Downloaded binary: {bin_url} to {fpath}")

setup(name='tomato',
      version=__version__,
      author='Sertan Senturk',
      author_email='contact AT sertansenturk DOT com',
      maintainer='Sertan Senturk',
      maintainer_email='contact AT sertansenturk DOT com',
      url='http://sertansenturk.com',
      description='Turkish-Ottoman Makam (M)usic Analysis TOolbox',
      long_description="""\
Turkish-Ottoman Makam (M)usic Analysis TOolbox
----------------------------------------------
tomato is a comprehensive and easy-to-use toolbox for the analysis of audio
recordings and music scores of Turkish-Ottoman makam music.
The aim of the toolbox is to allow the user to easily analyze large-scale
audio recording and music score collections of Turkish-Ottoman makam music,
using the state of the art methodologies specifically designed for the
necessities of this tradition. The analysis results can then be further used
for several tasks such as automatic content description, music
discovery/recommendation and musicological analysis.
      """,
      download_url='https://github.com/sertansenturk/tomato/releases/tag/'
                   'v{0:s}'.format(__version__),
      classifiers=[
          'Development Status :: 4 - Beta',
          'Environment :: Console',
          'Intended Audience :: Science/Research',
          'Intended Audience :: Information Technology',
          'License :: OSI Approved :: GNU Affero General Public License v3 or '
          'later (AGPLv3+)',
          'Natural Language :: English'
          'Operating System :: MacOS :: MacOS X',
          'Operating System :: POSIX :: Linux',
          'Programming Language :: Python :: 3',
          'Programming Language :: Python :: 3.5',
          'Programming Language :: Python :: 3.6',
          'Programming Language :: Python :: 3.7',
          'Topic :: Multimedia :: Sound/Audio :: Analysis',
          'Topic :: Scientific/Engineering :: Information Analysis',
          ],
      platforms='Linux, MacOS X',
      license='agpl 3.0',
      keywords=(
          "music-scores analysis tomato audio-recordings lilypond tonic "
          "makam-music score music-information-retrieval "
          "computational-analysis"),
      packages=find_packages(exclude=['contrib', 'docs', 'tests']),
      include_package_data=True,
      python_requires='>=3.5, <3.8',
      install_requires=[
          "numpy>=1.9.0"  # numerical operations
          "scipy>=0.17.0",  # temporary mat file saving for MCR binary inputs
          "pandas>=0.18.0",  # tabular data processing
          "matplotlib>=1.5.1",  # plotting
          "json_tricks>=3.12.1",  # saving json files with classes and numpy
          "eyeD3>=0.7.5",  # reading metadata embedded in the audio recordings
          "six>=1.10.0",  # Python 2*3 support
          "future>=0.15.2",  # Python 2*3 support
          "python-Levenshtein>=0.12.0",  # semiotic structure labeling
          "networkx>=1.11"  # semiotic structure labeling clique computation
          "lxml>=3.6.0",  # musicxml conversion
          "musicbrainzngs>=0.6"  # metadata crawling from musicbrainz
          "essentia>=2.1b5;platform_system=='Linux'"  # audio signal processing
          ],
      cmdclass={'install': CustomInstall},
      )
<|endoftext|>


<commit_before># -*- coding: utf-8 -*-

# Authors: Sung Jun Joo; Jason Yeatman; Kambiz Tavabi <ktavabi@gmail.com>
#
#
# License: BSD (3-clause)

import numpy as np
import mnefun
import os
#import glob
os.chdir('/home/sjjoo/git/BrainTools/projects/NLR_MEG')
from score import score
from nlr_organizeMEG_mnefun import nlr_organizeMEG_mnefun
import mne
import time
#import pycuda.driver
#import pycuda.autoinit

t0 = time.time()

mne.set_config('MNE_USE_CUDA', 'true')

# At Possum projects folder mounted in the local disk
raw_dir = '/mnt/diskArray/projects/MEG/r21/raw'

# At local hard drive
out_dir = '/mnt/scratch/r21'

if not os.path.isdir(out_dir):
    os.mkdir(out_dir)

os.chdir(out_dir)
#
#%%
out = ['joo_sung_session']

for n, s in enumerate(out):
    print(s)

for n, s in enumerate(out):
    params = mnefun.Params(tmin=-0.1, tmax=40, n_jobs=18, # t_adjust was -39e-3
                       decim=2, n_jobs_mkl=1, proj_sfreq=250,
                       n_jobs_fir='cuda', n_jobs_resample='cuda',
                       filter_length='5s', epochs_type='fif', lp_cut=40.,
#                       hp_cut=0.15,hp_trans=0.1,
                       bmin=-0.1, auto_bad=20., plot_raw=False)
#                       bem_type = '5120-5120-5120')
    params.subjects = [s]
    params.sss_type = 'python'
    params.sss_regularize = 'in' # 'in' by default
    params.tsss_dur = 8. # 60 for adults with not much head movements. This was set to 6.
    params.st_correlation = 0.9

    params.auto_bad_meg_thresh = 10 # THIS SHOULD NOT BE SO HIGH!

    params.trans_to = None #'median'

    params.t_adjust = -44e-3 # time delay from the trigger. It's due to set trigger function. I don't know why...

    #print("Running " + str(len(params.subjects)) + ' Subjects')
#    print("\n\n".join(params.subjects))
    print("\n\n")
    print("Running " + str(params.subjects))
    print("\n\n")

    params.subject_indices = np.arange(0,len(params.subjects))

    params.structurals =[None] * len(params.subjects)

    params.run_names = ['%s_1', '%s_3']

    params.dates = [(2014, 0, 00)] * len(params.subjects)
    #params.subject_indices = [0]
    params.score = score  # scoring function to use
    params.plot_drop_logs = False
    params.on_missing = 'warning'
    #params.acq_ssh = 'kambiz@minea.ilabs.uw.edu'  # minea - 172.28.161.8
    #params.acq_dir = '/sinuhe/data03/jason_words'

#    params.acq_ssh = 'jason@minea.ilabs.uw.edu'  # minea - 172.28.161.8
#    params.acq_dir = '/sinuhe/data03/jason_words'
    params.sws_ssh = 'jason@kasga.ilabs.uw.edu'  # kasga - 172.28.161.8
    params.sws_dir = '/data05/jason/NLR'

    #params.mf_args = '-hpie 30 -hpig .8 -hpicons' # sjjoo-20160826: We are doing SSS using python

    # epoch

    params.reject = dict(grad=3000e-13, mag=4.0e-12)
#    params.reject = dict(grad=4000e-13, mag=4.0e-12)

    params.ssp_eog_reject = dict(grad=params.reject['grad'], mag=params.reject['mag'], eog=np.inf)
    params.ssp_ecg_reject = dict(grad=params.reject['grad'], mag=params.reject['mag'], ecg=np.inf)

    params.flat = dict(grad=1e-13, mag=1e-15)

    params.auto_bad_reject = dict(grad=2*params.reject['grad'], mag=2*params.reject['mag'])

    params.auto_bad_flat = params.flat

    params.cov_method = 'shrunk'

    params.get_projs_from = range(len(params.run_names))
    params.inv_names = ['%s']
    params.inv_runs = [range(0, len(params.run_names))]
    params.runs_empty = []

    params.proj_nums = [[0, 0, 0],  # ECG: grad/mag/eeg
                        [1, 1, 0],  # EOG # sjjoo-20160826: was 3
                        [0, 0, 0]]  # Continuous (from ERM)

    # The scoring function needs to produce an event file with these values
    params.in_names = ['start']

    params.in_numbers = [1]

    # These lines define how to translate the above event types into evoked files
    params.analyses = [
        'All'
        ]

    params.out_names = [
        ['ALL']
    ]

    params.out_numbers = [
        [1]
        ]

    params.must_match = [
        [],
        ]
    # Set what will run
    mnefun.do_processing(
        params,
        fetch_raw=False,     # Fetch raw recording files from acquisition machine
        do_score=False,      # Do scoring to slice data into trials

        # Before running SSS, make SUBJ/raw_fif/SUBJ_prebad.txt file with
        # space-separated list of bad MEG channel numbers
        push_raw=False,      # Push raw files and SSS script to SSS workstation
        do_sss=True,        # Run SSS remotely (on sws) or locally with mne-python
        fetch_sss=False,     # Fetch SSSed files from SSS workstation
        do_ch_fix=False,     # Fix channel ordering

        # Before running SSP, examine SSS'ed files and make
        # SUBJ/bads/bad_ch_SUBJ_post-sss.txt; usually, this should only contain EEG
        # channels.
        gen_ssp=True,       # Generate SSP vectors
        apply_ssp=True,     # Apply SSP vectors and filtering
        plot_psd=True,      # Plot raw data power spectra
        write_epochs=True,  # Write epochs to disk
        gen_covs=True,      # Generate covariances

        # Make SUBJ/trans/SUBJ-trans.fif using mne_analyze; needed for fwd calc.
        gen_fwd=False,       # Generate forward solutions (and src space if needed)
        gen_inv=False,       # Generate inverses
        gen_report=False,    # Write mne report html of results to disk
        print_status=False,  # Print completeness status update
    )

print('%i sec' % (time.time() - t0,))
<commit_msg>ssvep analysis code<commit_after># -*- coding: utf-8 -*-

# Authors: Sung Jun Joo; Jason Yeatman; Kambiz Tavabi <ktavabi@gmail.com>
#
#
# License: BSD (3-clause)

import numpy as np
import mnefun
import os
#import glob
os.chdir('/home/sjjoo/git/BrainTools/projects/NLR_MEG')
from score import score
from nlr_organizeMEG_mnefun import nlr_organizeMEG_mnefun
import mne
import time
#import pycuda.driver
#import pycuda.autoinit

t0 = time.time()

mne.set_config('MNE_USE_CUDA', 'true')

# At Possum projects folder mounted in the local disk
raw_dir = '/mnt/diskArray/projects/MEG/r21/raw'

# At local hard drive
out_dir = '/mnt/scratch/r21'

if not os.path.isdir(out_dir):
    os.mkdir(out_dir)

os.chdir(out_dir)
#
#%%
out = ['pmd']

for n, s in enumerate(out):
    print(s)

for n, s in enumerate(out):
    params = mnefun.Params(tmin=-0.1, tmax=40, n_jobs=18, # t_adjust was -39e-3
                       decim=2, n_jobs_mkl=1, proj_sfreq=250,
                       n_jobs_fir='cuda', n_jobs_resample='cuda',
                       filter_length='5s', epochs_type='fif', lp_cut=40.,
#                       hp_cut=0.15,hp_trans=0.1,
                       bmin=-0.1, auto_bad=20., plot_raw=False)
#                       bem_type = '5120-5120-5120')
    params.subjects = [s]
    params.sss_type = 'python'
    params.sss_regularize = 'in' # 'in' by default
    params.tsss_dur = 16. # 60 for adults with not much head movements. This was set to 6.
    params.st_correlation = 0.98

    params.auto_bad_meg_thresh = 10 # THIS SHOULD NOT BE SO HIGH!

    params.trans_to = 'median'

    params.t_adjust = -44e-3 # time delay from the trigger. It's due to set trigger function. I don't know why...

    #print("Running " + str(len(params.subjects)) + ' Subjects')
#    print("\n\n".join(params.subjects))
    print("\n\n")
    print("Running " + str(params.subjects))
    print("\n\n")

    params.subject_indices = np.arange(0,len(params.subjects))

    params.structurals =[None] * len(params.subjects)

    params.run_names = ['%s_1', '%s_2', '%s_3', '%s_4']

    params.dates = [(2014, 0, 00)] * len(params.subjects)
    #params.subject_indices = [0]
    params.score = score  # scoring function to use
    params.plot_drop_logs = False
    params.on_missing = 'warning'
    #params.acq_ssh = 'kambiz@minea.ilabs.uw.edu'  # minea - 172.28.161.8
    #params.acq_dir = '/sinuhe/data03/jason_words'

#    params.acq_ssh = 'jason@minea.ilabs.uw.edu'  # minea - 172.28.161.8
#    params.acq_dir = '/sinuhe/data03/jason_words'
    params.sws_ssh = 'jason@kasga.ilabs.uw.edu'  # kasga - 172.28.161.8
    params.sws_dir = '/data05/jason/NLR'

    #params.mf_args = '-hpie 30 -hpig .8 -hpicons' # sjjoo-20160826: We are doing SSS using python

    # epoch

    params.reject = dict(grad=3000e-13, mag=4.0e-12)
#    params.reject = dict(grad=4000e-13, mag=4.0e-12)

    params.ssp_eog_reject = dict(grad=params.reject['grad'], mag=params.reject['mag'], eog=np.inf)
    params.ssp_ecg_reject = dict(grad=params.reject['grad'], mag=params.reject['mag'], ecg=np.inf)

    params.flat = dict(grad=1e-13, mag=1e-15)

    params.auto_bad_reject = dict(grad=2*params.reject['grad'], mag=2*params.reject['mag'])

    params.auto_bad_flat = params.flat

    params.cov_method = 'shrunk'

    params.get_projs_from = range(len(params.run_names))
    params.inv_names = ['%s']
    params.inv_runs = [range(0, len(params.run_names))]
    params.runs_empty = []

    params.proj_nums = [[0, 0, 0],  # ECG: grad/mag/eeg
                        [1, 1, 0],  # EOG # sjjoo-20160826: was 3
                        [0, 0, 0]]  # Continuous (from ERM)

    # The scoring function needs to produce an event file with these values
    params.in_names = ['start']

    params.in_numbers = [1]

    # These lines define how to translate the above event types into evoked files
    params.analyses = [
        'All'
        ]

    params.out_names = [
        ['ALL']
    ]

    params.out_numbers = [
        [1]
        ]

    params.must_match = [
        [],
        ]
    # Set what will run
    mnefun.do_processing(
        params,
        fetch_raw=False,     # Fetch raw recording files from acquisition machine
        do_score=False,      # Do scoring to slice data into trials

        # Before running SSS, make SUBJ/raw_fif/SUBJ_prebad.txt file with
        # space-separated list of bad MEG channel numbers
        push_raw=False,      # Push raw files and SSS script to SSS workstation
        do_sss=True,        # Run SSS remotely (on sws) or locally with mne-python
        fetch_sss=False,     # Fetch SSSed files from SSS workstation
        do_ch_fix=False,     # Fix channel ordering

        # Before running SSP, examine SSS'ed files and make
        # SUBJ/bads/bad_ch_SUBJ_post-sss.txt; usually, this should only contain EEG
        # channels.
        gen_ssp=False,       # Generate SSP vectors
        apply_ssp=False,     # Apply SSP vectors and filtering
        plot_psd=False,      # Plot raw data power spectra
        write_epochs=False,  # Write epochs to disk
        gen_covs=False,      # Generate covariances

        # Make SUBJ/trans/SUBJ-trans.fif using mne_analyze; needed for fwd calc.
        gen_fwd=False,       # Generate forward solutions (and src space if needed)
        gen_inv=False,       # Generate inverses
        gen_report=False,    # Write mne report html of results to disk
        print_status=False,  # Print completeness status update
    )

print('%i sec' % (time.time() - t0,))
<|endoftext|>


<commit_before>'''
@author: David Losada Carballo <david@tuxpiper.com>
'''

from setuptools import setup, find_packages

setup(
    name = "raduga",
    version = "0.0.4",
    packages = find_packages(),

    description = ("Infrastructure-as-code framework for AWS"),
    author = "David Losada Carballo",
    author_email = "david@tuxpiper.com",
    install_requires = ['cloudcast>=0.0.7', 'docopt>=0.6.1', 'boto>=2.26.1', 'setuptools==3.3'],
    license = 'MIT',
    keywords = "aws internet cloud infrastructure deployment automation",
    long_description = open('README.md').read(),
    url = "http://github.com/tuxpiper/raduga",
    zip_safe = False,
    entry_points = {
        'console_scripts': [
            'raduga = raduga.main:main',
        ]
    },
    package_data = {
        # Script files that contain initial bootstrap sequences
        'raduga': ['cfn/*']
    },
    classifiers=[
        "Development Status :: 2 - Pre-Alpha",
        "Topic :: System",
        "Environment :: Console",
        "Intended Audience :: System Administrators",
        "License :: OSI Approved :: MIT License",
        "Programming Language :: Python"
    ],
)
<commit_msg>0.0.5 - require cloudcast 0.0.8<commit_after>'''
@author: David Losada Carballo <david@tuxpiper.com>
'''

from setuptools import setup, find_packages

setup(
    name = "raduga",
    version = "0.0.5",
    packages = find_packages(),

    description = ("Infrastructure-as-code framework for AWS"),
    author = "David Losada Carballo",
    author_email = "david@tuxpiper.com",
    install_requires = ['cloudcast>=0.0.8', 'docopt>=0.6.1', 'boto>=2.26.1', 'setuptools==3.3'],
    license = 'MIT',
    keywords = "aws internet cloud infrastructure deployment automation",
    long_description = open('README.md').read(),
    url = "http://github.com/tuxpiper/raduga",
    zip_safe = False,
    entry_points = {
        'console_scripts': [
            'raduga = raduga.main:main',
        ]
    },
    package_data = {
        # Script files that contain initial bootstrap sequences
        'raduga': ['cfn/*']
    },
    classifiers=[
        "Development Status :: 2 - Pre-Alpha",
        "Topic :: System",
        "Environment :: Console",
        "Intended Audience :: System Administrators",
        "License :: OSI Approved :: MIT License",
        "Programming Language :: Python"
    ],
)
<|endoftext|>


<commit_before>from setuptools import find_packages
from setuptools import setup

setup(
    name="mpienv",
    version="0.1.1",
    description="MPI environment switcher",
    author="Keisuke Fukuda",
    author_email="keisukefukuda@gmail.com",
    url="https://github.com/keisukefukuda/mpienv",
    scripts=['bin/mpienv-init'],
    packages=find_packages(),
)
<commit_msg>release 0.1.2<commit_after>from setuptools import find_packages
from setuptools import setup

setup(
    name="mpienv",
    version="0.1.2",
    description="MPI environment switcher",
    author="Keisuke Fukuda",
    author_email="keisukefukuda@gmail.com",
    url="https://github.com/keisukefukuda/mpienv",
    scripts=['bin/mpienv-init'],
    packages=find_packages(),
)
<|endoftext|>


<commit_before>#!/usr/bin/python

"""px - ps and top for Human Beings
     https://github.com/walles/px

Usage:
  px [--debug] [--sort=cpupercent] [--no-username] [filter string]
  px [--debug] [--no-pager] [--color] <PID>
  px [--debug] --top [filter string]
  px --install
  px --help
  px --version

In the base case, px list all processes much like ps, but with the most
interesting processes last. A process is considered interesting if it has high
memory usage, has used lots of CPU or has been started recently.

If the optional filter string parameter is specified, processes will be shown if:
* The filter matches the user name of the process
* The filter matches a substring of the command line

If the optional PID parameter is specified, you'll get detailed information
about that particular PID.

In --top mode, a new process list is shown every second. The most CPU heavy
processes are on top. In this mode, CPU times are counted from when you first
invoked px, rather than from when each process started. This gives you a picture
of which processes are most active right now.

--top: Show a continuously refreshed process list
--debug: Print debug logs (if any) after running
--install: Install /usr/local/bin/px and /usr/local/bin/ptop
--no-pager: Print PID info to stdout rather than to a pager
--sort=cpupercent: Order processes by CPU percentage only
--no-username: Don't show the username column in px output
--color: Force color output even when piping
--help: Print this help
--version: Print version information
"""

import operator
import platform
import logging
import sys
import io
import os

from . import px_pager
from . import px_install
from . import px_process
from . import px_terminal
from . import px_processinfo

from typing import Optional, List

ERROR_REPORTING_HEADER = """
---

Problems detected, please send this text to one of:
* https://github.com/walles/px/issues/new
* johan.walles@gmail.com
"""

def install(argv: List[str]) -> None:
    """Find full path to self"""
    if not argv:
        sys.stderr.write("ERROR: Can't find myself, can't install\n")
        return

    px_pex = argv[0]
    if not px_pex.endswith(".pex"):
        sys.stderr.write("ERROR: Not running from .pex file, can't install\n")
        return

    px_install.install(px_pex, "/usr/local/bin/px")
    px_install.install(px_pex, "/usr/local/bin/ptop")

# This is the setup.py entry point
def main():
    argv = list(sys.argv)

    loglevel = logging.ERROR
    while "--debug" in argv:
        argv.remove("--debug")
        loglevel = logging.DEBUG

    stringIO = io.StringIO()
    configureLogging(loglevel, stringIO)

    try:
        _main(argv)
    except Exception:  # pylint: disable=broad-except
        LOG = logging.getLogger(__name__)
        LOG.exception("Uncaught Exception")

    handleLogMessages(stringIO.getvalue())

# This method inspired by: https://stackoverflow.com/a/9534960/473672
def configureLogging(loglevel: int, stringIO: io.StringIO) -> None:
    rootLogger = logging.getLogger()
    rootLogger.setLevel(loglevel)

    handlers = []
    for handler in rootLogger.handlers:
        handlers.append(handler)
    for handler in handlers:
        rootLogger.removeHandler(handler)

    handler = logging.StreamHandler(stringIO)
    formatter = logging.Formatter(
        fmt="%(asctime)s %(levelname)-8s %(message)s", datefmt="%Y-%m-%d %H:%M:%S%Z"
    )
    handler.setFormatter(formatter)

    rootLogger.addHandler(handler)

def handleLogMessages(messages: Optional[str]) -> None:
    if not messages:
        return

    sys.stderr.write(ERROR_REPORTING_HEADER)
    sys.stderr.write("\n")

    # If this fails, run "tox.sh" once and the "version.py" file will be created
    # for you.
    #
    # NOTE: If we "import version" at the top of this file, we will depend on it
    # even if we don't use it. And this will make test avoidance fail to avoid
    # px.py tests every time you make a new commit (because committing recreates
    # version.py).
    from . import version  # pylint: disable=import-outside-toplevel

    sys.stderr.write("px version: " + version.VERSION + "\n")

    sys.stderr.write("\n")
    sys.stderr.write("Python version: " + sys.version + "\n")
    sys.stderr.write("\n")
    sys.stderr.write("Platform info: " + platform.platform() + "\n")
    sys.stderr.write("\n")
    sys.stderr.write(messages)
    sys.stderr.write("\n")
    sys.exit(1)

def _main(argv: List[str]) -> None:

    if "--install" in argv:
        install(argv)
        return

    if "--help" in argv:
        print(__doc__)
        return

    if "--version" in argv:
        # If this fails, run "tox.sh" once and the "version.py" file will be created for you.
        #
        # NOTE: If we "import version" at the top of this file, we will depend on it even if
        # we don't use it. And this will make test avoidance fail to avoid px.py tests every
        # time you make a new commit (because committing recreates version.py).
        from . import version  # pylint: disable=import-outside-toplevel

        print(version.VERSION)
        return

    with_pager: Optional[bool] = None
    with_color: Optional[bool] = None
    with_username = True
    top: bool = False
    sort_cpupercent: bool = False

    while "--no-pager" in argv:
        with_pager = False
        argv.remove("--no-pager")
    if with_pager is None:
        with_pager = sys.stdout.isatty()

    while "--color" in argv:
        with_color = True
        argv.remove("--color")
    if with_color is None:
        with_color = sys.stdout.isatty()
    if not with_color:
        px_terminal.disable_color()

    while "--top" in argv:
        top = True
        argv.remove("--top")
    if os.path.basename(argv[0]).endswith("top"):
        top = True

    while "--sort=cpupercent" in argv:
        sort_cpupercent = True
        argv.remove("--sort=cpupercent")

    while "--no-username" in argv:
        # Ref: https://github.com/walles/px/issues/88#issuecomment-945099485
        with_username = False
        argv.remove("--no-username")

    if len(argv) > 2:
        sys.stderr.write("ERROR: Expected zero or one argument but got more\n\n")
        print(__doc__)
        sys.exit(1)

    search = ""
    if len(argv) == 2:
        search = argv[1]

    if top:
        # Pulling px_top in on demand like this improves test result caching
        from . import px_top  # pylint: disable=import-outside-toplevel

        px_top.top(search=search)
        return

    try:
        pid = int(search)
        if not with_pager:
            px_processinfo.print_pid_info(sys.stdout.fileno(), pid)
            return

        # Page it!
        processes = px_process.get_all()
        process = px_processinfo.find_process_by_pid(pid, processes)
        if not process:
            sys.exit("No such PID: {}\n".format(pid))

        px_pager.page_process_info(process, processes)
        return
    except ValueError:
        # It's a search filter and not a PID, keep moving
        pass

    procs = list(filter(lambda p: p.match(search), px_process.get_all()))

    columns: Optional[int] = None
    try:
        _, columns = px_terminal.get_window_size()
    except px_terminal.TerminalError:
        columns = None

    # Print the most interesting processes last; there are lots of processes and
    # the end of the list is where your eyes will be when you get the prompt back.
    procs = px_process.order_best_last(procs)
    if sort_cpupercent:
        procs = list(filter(lambda p: p.cpu_percent is not None, procs))
        procs = sorted(procs, key=operator.attrgetter("cpu_percent"))
    lines = px_terminal.to_screen_lines(procs, None, None, with_username)

    if columns:
        for line in lines:
            print(px_terminal.crop_ansi_string_at_length(line, columns))
    else:
        print("\n".join(lines))

if __name__ == "__main__":
    main()
<commit_msg>fstringify px.py<commit_after>#!/usr/bin/python

"""px - ps and top for Human Beings
     https://github.com/walles/px

Usage:
  px [--debug] [--sort=cpupercent] [--no-username] [filter string]
  px [--debug] [--no-pager] [--color] <PID>
  px [--debug] --top [filter string]
  px --install
  px --help
  px --version

In the base case, px list all processes much like ps, but with the most
interesting processes last. A process is considered interesting if it has high
memory usage, has used lots of CPU or has been started recently.

If the optional filter string parameter is specified, processes will be shown if:
* The filter matches the user name of the process
* The filter matches a substring of the command line

If the optional PID parameter is specified, you'll get detailed information
about that particular PID.

In --top mode, a new process list is shown every second. The most CPU heavy
processes are on top. In this mode, CPU times are counted from when you first
invoked px, rather than from when each process started. This gives you a picture
of which processes are most active right now.

--top: Show a continuously refreshed process list
--debug: Print debug logs (if any) after running
--install: Install /usr/local/bin/px and /usr/local/bin/ptop
--no-pager: Print PID info to stdout rather than to a pager
--sort=cpupercent: Order processes by CPU percentage only
--no-username: Don't show the username column in px output
--color: Force color output even when piping
--help: Print this help
--version: Print version information
"""

import operator
import platform
import logging
import sys
import io
import os

from . import px_pager
from . import px_install
from . import px_process
from . import px_terminal
from . import px_processinfo

from typing import Optional, List

ERROR_REPORTING_HEADER = """
---

Problems detected, please send this text to one of:
* https://github.com/walles/px/issues/new
* johan.walles@gmail.com
"""

def install(argv: List[str]) -> None:
    """Find full path to self"""
    if not argv:
        sys.stderr.write("ERROR: Can't find myself, can't install\n")
        return

    px_pex = argv[0]
    if not px_pex.endswith(".pex"):
        sys.stderr.write("ERROR: Not running from .pex file, can't install\n")
        return

    px_install.install(px_pex, "/usr/local/bin/px")
    px_install.install(px_pex, "/usr/local/bin/ptop")

# This is the setup.py entry point
def main():
    argv = list(sys.argv)

    loglevel = logging.ERROR
    while "--debug" in argv:
        argv.remove("--debug")
        loglevel = logging.DEBUG

    stringIO = io.StringIO()
    configureLogging(loglevel, stringIO)

    try:
        _main(argv)
    except Exception:  # pylint: disable=broad-except
        LOG = logging.getLogger(__name__)
        LOG.exception("Uncaught Exception")

    handleLogMessages(stringIO.getvalue())

# This method inspired by: https://stackoverflow.com/a/9534960/473672
def configureLogging(loglevel: int, stringIO: io.StringIO) -> None:
    rootLogger = logging.getLogger()
    rootLogger.setLevel(loglevel)

    handlers = []
    for handler in rootLogger.handlers:
        handlers.append(handler)
    for handler in handlers:
        rootLogger.removeHandler(handler)

    handler = logging.StreamHandler(stringIO)
    formatter = logging.Formatter(
        fmt="%(asctime)s %(levelname)-8s %(message)s", datefmt="%Y-%m-%d %H:%M:%S%Z"
    )
    handler.setFormatter(formatter)

    rootLogger.addHandler(handler)

def handleLogMessages(messages: Optional[str]) -> None:
    if not messages:
        return

    sys.stderr.write(ERROR_REPORTING_HEADER)
    sys.stderr.write("\n")

    # If this fails, run "tox.sh" once and the "version.py" file will be created
    # for you.
    #
    # NOTE: If we "import version" at the top of this file, we will depend on it
    # even if we don't use it. And this will make test avoidance fail to avoid
    # px.py tests every time you make a new commit (because committing recreates
    # version.py).
    from . import version  # pylint: disable=import-outside-toplevel

    sys.stderr.write("px version: " + version.VERSION + "\n")

    sys.stderr.write("\n")
    sys.stderr.write("Python version: " + sys.version + "\n")
    sys.stderr.write("\n")
    sys.stderr.write("Platform info: " + platform.platform() + "\n")
    sys.stderr.write("\n")
    sys.stderr.write(messages)
    sys.stderr.write("\n")
    sys.exit(1)

def _main(argv: List[str]) -> None:

    if "--install" in argv:
        install(argv)
        return

    if "--help" in argv:
        print(__doc__)
        return

    if "--version" in argv:
        # If this fails, run "tox.sh" once and the "version.py" file will be created for you.
        #
        # NOTE: If we "import version" at the top of this file, we will depend on it even if
        # we don't use it. And this will make test avoidance fail to avoid px.py tests every
        # time you make a new commit (because committing recreates version.py).
        from . import version  # pylint: disable=import-outside-toplevel

        print(version.VERSION)
        return

    with_pager: Optional[bool] = None
    with_color: Optional[bool] = None
    with_username = True
    top: bool = False
    sort_cpupercent: bool = False

    while "--no-pager" in argv:
        with_pager = False
        argv.remove("--no-pager")
    if with_pager is None:
        with_pager = sys.stdout.isatty()

    while "--color" in argv:
        with_color = True
        argv.remove("--color")
    if with_color is None:
        with_color = sys.stdout.isatty()
    if not with_color:
        px_terminal.disable_color()

    while "--top" in argv:
        top = True
        argv.remove("--top")
    if os.path.basename(argv[0]).endswith("top"):
        top = True

    while "--sort=cpupercent" in argv:
        sort_cpupercent = True
        argv.remove("--sort=cpupercent")

    while "--no-username" in argv:
        # Ref: https://github.com/walles/px/issues/88#issuecomment-945099485
        with_username = False
        argv.remove("--no-username")

    if len(argv) > 2:
        sys.stderr.write("ERROR: Expected zero or one argument but got more\n\n")
        print(__doc__)
        sys.exit(1)

    search = ""
    if len(argv) == 2:
        search = argv[1]

    if top:
        # Pulling px_top in on demand like this improves test result caching
        from . import px_top  # pylint: disable=import-outside-toplevel

        px_top.top(search=search)
        return

    try:
        pid = int(search)
        if not with_pager:
            px_processinfo.print_pid_info(sys.stdout.fileno(), pid)
            return

        # Page it!
        processes = px_process.get_all()
        process = px_processinfo.find_process_by_pid(pid, processes)
        if not process:
            sys.exit(f"No such PID: {pid}")

        px_pager.page_process_info(process, processes)
        return
    except ValueError:
        # It's a search filter and not a PID, keep moving
        pass

    procs = list(filter(lambda p: p.match(search), px_process.get_all()))

    columns: Optional[int] = None
    try:
        _, columns = px_terminal.get_window_size()
    except px_terminal.TerminalError:
        columns = None

    # Print the most interesting processes last; there are lots of processes and
    # the end of the list is where your eyes will be when you get the prompt back.
    procs = px_process.order_best_last(procs)
    if sort_cpupercent:
        procs = list(filter(lambda p: p.cpu_percent is not None, procs))
        procs = sorted(procs, key=operator.attrgetter("cpu_percent"))
    lines = px_terminal.to_screen_lines(procs, None, None, with_username)

    if columns:
        for line in lines:
            print(px_terminal.crop_ansi_string_at_length(line, columns))
    else:
        print("\n".join(lines))

if __name__ == "__main__":
    main()
<|endoftext|>


<commit_before># Copyright (c) 2012 Spotify AB
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

import os

from setuptools import setup

def get_static_files(path):
    return [os.path.join(dirpath.replace("luigi/", ""), ext)
            for (dirpath, dirnames, filenames) in os.walk(path)
            for ext in ["*.html", "*.js", "*.css", "*.png",
                        "*.eot", "*.svg", "*.ttf", "*.woff", "*.woff2"]]

luigi_package_data = sum(map(get_static_files, ["luigi/static", "luigi/templates"]), [])

readme_note = """\
.. note::

   For the latest source, discussion, etc, please visit the
   `GitHub repository <https://github.com/spotify/luigi>`_\n\n
"""

with open('README.rst') as fobj:
    long_description = readme_note + fobj.read()

install_requires = [
    'pymysql',
    'tornado<5.0',
    'python-daemon<3.0',
]

if os.environ.get('READTHEDOCS', None) == 'True':
    # So that we can build documentation for luigi.db_task_history and luigi.contrib.sqla
    install_requires.append('sqlalchemy')
    # readthedocs don't like python-daemon, see #1342
    install_requires.remove('python-daemon<3.0')

setup(
    name='houzz_luigi',
    version='2.0.1',
    description='Workflow mgmgt + task scheduling + dependency resolution',
    long_description=long_description,
    author='Erik Bernhardsson',
    author_email='erikbern@spotify.com',
    url='https://github.com/spotify/luigi',
    license='Apache License 2.0',
    packages=[
        'luigi',
        'luigi.contrib',
        'luigi.contrib.hdfs',
        'luigi.tools'
    ],
    package_data={
        'luigi': luigi_package_data
    },
    entry_points={
        'console_scripts': [
            'luigi = luigi.cmdline:luigi_run',
            'luigid = luigi.cmdline:luigid',
            'luigi-grep = luigi.tools.luigi_grep:main',
            'luigi-deps = luigi.tools.deps:main',
        ]
    },
    install_requires=install_requires,
    classifiers=[
        'Development Status :: 5 - Production/Stable',
        'Environment :: Console',
        'Environment :: Web Environment',
        'Intended Audience :: Developers',
        'Intended Audience :: System Administrators',
        'License :: OSI Approved :: Apache Software License',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: 3.3',
        'Programming Language :: Python :: 3.4',
        'Topic :: System :: Monitoring',
    ],
)
<commit_msg>Increments houzz_luigi version number<commit_after># Copyright (c) 2012 Spotify AB
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

import os

from setuptools import setup

def get_static_files(path):
    return [os.path.join(dirpath.replace("luigi/", ""), ext)
            for (dirpath, dirnames, filenames) in os.walk(path)
            for ext in ["*.html", "*.js", "*.css", "*.png",
                        "*.eot", "*.svg", "*.ttf", "*.woff", "*.woff2"]]

luigi_package_data = sum(map(get_static_files, ["luigi/static", "luigi/templates"]), [])

readme_note = """\
.. note::

   For the latest source, discussion, etc, please visit the
   `GitHub repository <https://github.com/spotify/luigi>`_\n\n
"""

with open('README.rst') as fobj:
    long_description = readme_note + fobj.read()

install_requires = [
    'pymysql',
    'tornado<5.0',
    'python-daemon<3.0',
]

if os.environ.get('READTHEDOCS', None) == 'True':
    # So that we can build documentation for luigi.db_task_history and luigi.contrib.sqla
    install_requires.append('sqlalchemy')
    # readthedocs don't like python-daemon, see #1342
    install_requires.remove('python-daemon<3.0')

setup(
    name='houzz_luigi',
    version='2.0.2',
    description='Workflow mgmgt + task scheduling + dependency resolution',
    long_description=long_description,
    author='Erik Bernhardsson',
    author_email='erikbern@spotify.com',
    url='https://github.com/spotify/luigi',
    license='Apache License 2.0',
    packages=[
        'luigi',
        'luigi.contrib',
        'luigi.contrib.hdfs',
        'luigi.tools'
    ],
    package_data={
        'luigi': luigi_package_data
    },
    entry_points={
        'console_scripts': [
            'luigi = luigi.cmdline:luigi_run',
            'luigid = luigi.cmdline:luigid',
            'luigi-grep = luigi.tools.luigi_grep:main',
            'luigi-deps = luigi.tools.deps:main',
        ]
    },
    install_requires=install_requires,
    classifiers=[
        'Development Status :: 5 - Production/Stable',
        'Environment :: Console',
        'Environment :: Web Environment',
        'Intended Audience :: Developers',
        'Intended Audience :: System Administrators',
        'License :: OSI Approved :: Apache Software License',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: 3.3',
        'Programming Language :: Python :: 3.4',
        'Topic :: System :: Monitoring',
    ],
)
<|endoftext|>


<commit_before># creates databases in mongodb
import sys

def leave(str):
    print(str)
    exit(1)

try:
    assert sys.version_info[0] == 3 and sys.version_info[1] > 5
except AssertionError:
    leave("you need to have python 3.6 or later.")

try:
    import config
    import psycopg2
except ImportError(config):
    leave("you need to make a config. please see example_config.py for help.")
except ImportError(psycopg2):
    leave("you need to install the requirements.")

for i in [config.dsn, config.token]:
    try:
        assert isinstance(i, str)
    except AssertionError:
        leave("please fill in the config file.")
cur = None
try:
    cur = psycopg2.connect(config.dsn).cursor()
except psycopg2.Error:
    leave("uh ur auth is wrong kiddo, or smthin")

# build tables
cur.execute("""CREATE TABLE IF NOT EXISTS tags
               (hash TEXT PRIMARY KEY, name TEXT, guild BIGINT, content TEXT, author BIGINT)""")

cur.execute("""CREATE TABLE IF NOT EXISTS configs (guild BIGINT PRIMARY KEY, currency BOOL NOT NULL DEFAULT True)""")

# initial tag from b1nZ for tags

cur.execute("""INSERT INTO tags (hash, name, guild, content) VALUES
            ('1ca25c85001011127a3db6712b5e425b4ad4672c9754535b81e72f99c784112e',
            'hello world',
            295341979800436736,
            80351110224678912""")

# initial config for memework
cur.execute("""INSERT INTO configs (guild, currency) VALUES (295341979800436736, True)""")

print("Done!")
<commit_msg>NOT NULL<commit_after># creates databases in mongodb
import sys

def leave(str):
    print(str)
    exit(1)

try:
    assert sys.version_info[0] == 3 and sys.version_info[1] > 5
except AssertionError:
    leave("you need to have python 3.6 or later.")

try:
    import config
    import psycopg2
except ImportError(config):
    leave("you need to make a config. please see example_config.py for help.")
except ImportError(psycopg2):
    leave("you need to install the requirements.")

for i in [config.dsn, config.token]:
    try:
        assert isinstance(i, str)
    except AssertionError:
        leave("please fill in the config file.")
cur = None
try:
    cur = psycopg2.connect(config.dsn).cursor()
except psycopg2.Error:
    leave("uh ur auth is wrong kiddo, or smthin")

# build tables
cur.execute("""CREATE TABLE IF NOT EXISTS tags
               (hash TEXT PRIMARY KEY NOT NULL,
               tag TEXT NOT NULL,
               guild BIGINT NOT NULL,
               content TEXT NOT NULL,
               author BIGINT NOT NULL)""")

cur.execute("""CREATE TABLE IF NOT EXISTS configs (guild BIGINT PRIMARY KEY, currency BOOL NOT NULL DEFAULT True)""")

# initial tag from b1nZ for tags

cur.execute("""INSERT INTO tags (hash, tag, guild, content, author) VALUES
            ('1ca25c85001011127a3db6712b5e425b4ad4672c9754535b81e72f99c784112e',
            'hello world',
            295341979800436736,
            'hello, im ghost of b1nzy who wrote this tag',
            80351110224678912""")

# initial config for memework
cur.execute("""INSERT INTO configs (guild, currency) VALUES (295341979800436736, True)""")

print("Done!")
<|endoftext|>


<commit_before># Copyright (c) 2009-2012 gocept gmbh & co. kg
# See also LICENSE.txt

from setuptools import setup, find_packages

setup(
    name='zeit.content.cp',
    version='2.5.1.dev0',
    author='gocept',
    author_email='mail@gocept.com',
    url='https://intra.gocept.com/projects/projects/zeit-cms',
    description="""\
""",
    packages=find_packages('src'),
    package_dir={'': 'src'},
    include_package_data=True,
    zip_safe=False,
    license='gocept proprietary',
    namespace_packages=['zeit', 'zeit.content'],
    install_requires=[
        'cssselect',
        'feedparser',
        'gocept.cache',
        'gocept.httpserverlayer',
        'gocept.jslint>=0.2',
        'gocept.lxml',
        'gocept.mochikit>=1.4.2.2',
        'gocept.runner>-0.4',
        'gocept.selenium>=0.6',
        'grokcore.component',
        'lxml',
        'requests',
        'setuptools',
        'zc.sourcefactory',
        'zeit.cms>=2.20.0.dev0',
        'zeit.content.image',
        'zeit.content.quiz>=0.4.2',
        'zeit.content.video',
        'zeit.edit >= 2.1.3',
        'zeit.find >= 2.3.0.dev0',
        'zope.app.appsetup',
        'zope.app.generations',
        'zope.app.pagetemplate',
        'zope.component',
        'zope.container>=3.8.1',
        'zope.event',
        'zope.formlib',
        'zope.i18n',
        'zope.interface',
        'zope.lifecycleevent',
        'zope.viewlet',
    ],
    entry_points={
        'console_scripts': [
            'refresh-feeds = zeit.content.cp.feed:refresh_all',
            'sweep-teasergroup-repository = zeit.content.cp.teasergroup'
            '.teasergroup:sweep_repository',
        ],
        'fanstatic.libraries': [
            'zeit_content_cp=zeit.content.cp.browser.resources:lib',
        ],
    },
)
<commit_msg>Re VIV-436: Bump version since we introduced new API (IAutomaticConfig)<commit_after># Copyright (c) 2009-2012 gocept gmbh & co. kg
# See also LICENSE.txt

from setuptools import setup, find_packages

setup(
    name='zeit.content.cp',
    version='2.6.0.dev0',
    author='gocept',
    author_email='mail@gocept.com',
    url='https://intra.gocept.com/projects/projects/zeit-cms',
    description="""\
""",
    packages=find_packages('src'),
    package_dir={'': 'src'},
    include_package_data=True,
    zip_safe=False,
    license='gocept proprietary',
    namespace_packages=['zeit', 'zeit.content'],
    install_requires=[
        'cssselect',
        'feedparser',
        'gocept.cache',
        'gocept.httpserverlayer',
        'gocept.jslint>=0.2',
        'gocept.lxml',
        'gocept.mochikit>=1.4.2.2',
        'gocept.runner>-0.4',
        'gocept.selenium>=0.6',
        'grokcore.component',
        'lxml',
        'requests',
        'setuptools',
        'zc.sourcefactory',
        'zeit.cms>=2.20.0.dev0',
        'zeit.content.image',
        'zeit.content.quiz>=0.4.2',
        'zeit.content.video',
        'zeit.edit >= 2.1.3',
        'zeit.find >= 2.3.0.dev0',
        'zope.app.appsetup',
        'zope.app.generations',
        'zope.app.pagetemplate',
        'zope.component',
        'zope.container>=3.8.1',
        'zope.event',
        'zope.formlib',
        'zope.i18n',
        'zope.interface',
        'zope.lifecycleevent',
        'zope.viewlet',
    ],
    entry_points={
        'console_scripts': [
            'refresh-feeds = zeit.content.cp.feed:refresh_all',
            'sweep-teasergroup-repository = zeit.content.cp.teasergroup'
            '.teasergroup:sweep_repository',
        ],
        'fanstatic.libraries': [
            'zeit_content_cp=zeit.content.cp.browser.resources:lib',
        ],
    },
)
<|endoftext|>