Example #1
0
def test_config():
    '''Create a Django configuration for running tests'''

    config = base_config()

    # If django-nose is installed, use it
    # You can do things like ./run_tests.py --with-coverage
    try:
        from pkg_resources import WorkingSet, DistributionNotFound
        working_set = WorkingSet()
        working_set.require('django_nose')
    except ImportError:
        print('setuptools not installed.  Weird.')
    except DistributionNotFound:
        print("django-nose not installed.  You'd like it.")
    else:
        config['INSTALLED_APPS'].append('django_nose')
        config['TEST_RUNNER'] = 'django_nose.NoseTestSuiteRunner'

    # Optionally update configuration
    try:
        import t_overrides
    except ImportError:
        pass
    else:
        config = t_overrides.update(config)

    return config
Example #2
0
def main():
    # Dynamically configure the Django settings with the minimum necessary to
    # get Django running tests
    INSTALLED_APPS = ['multigtfs']
    TEST_RUNNER = 'django.test.simple.DjangoTestSuiteRunner'

    # If django-nose is installed, use it
    # You can do things like ./run_tests.py --with-coverage
    try:
        from pkg_resources import WorkingSet, DistributionNotFound
        working_set = WorkingSet()
        working_set.require('django_nose')
    except ImportError:
        print 'setuptools not installed.  Weird.'
    except DistributionNotFound:
        print "django-nose not installed.  You'd like it."
    else:
        INSTALLED_APPS.append('django_nose')
        TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

    settings.configure(
        INSTALLED_APPS=INSTALLED_APPS,
        DATABASE_ENGINE='django.contrib.gis.db.backends.spatialite',
        DATABASES={
            'default': {
                'ENGINE': 'django.contrib.gis.db.backends.spatialite',
            }
        },
        DEBUG=True,
        TEMPLATE_DEBUG=True,
        TEST_RUNNER=TEST_RUNNER)

    from django.core import management
    failures = management.call_command('test')  # Will pull sysv args itself
    sys.exit(failures)
def main():
    # Dynamically configure the Django settings with the minimum necessary to
    # get Django running tests
    INSTALLED_APPS = ['multigtfs']
    TEST_RUNNER = 'django.test.simple.DjangoTestSuiteRunner'

    # If django-nose is installed, use it
    # You can do things like ./run_tests.py --with-coverage
    try:
        from pkg_resources import WorkingSet, DistributionNotFound
        working_set = WorkingSet()
        working_set.require('django_nose')
    except ImportError:
        print 'setuptools not installed.  Weird.'
    except DistributionNotFound:
        print "django-nose not installed.  You'd like it."
    else:
        INSTALLED_APPS.append('django_nose')
        TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

    settings.configure(
        INSTALLED_APPS=INSTALLED_APPS,
        # Django replaces this, but it still wants it. *shrugs*
        DATABASE_ENGINE='django.db.backends.sqlite3',
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
            }
        },
        DEBUG=True, TEMPLATE_DEBUG=True, TEST_RUNNER=TEST_RUNNER
    )

    from django.core import management
    failures = management.call_command('test')  # Will pull sysv args itself
    sys.exit(failures)
Example #4
0
def test_config():
    '''Create a Django configuration for running tests'''

    config = base_config()

    # If django-nose is installed, use it
    # You can do things like ./run_tests.py --with-coverage
    try:
        from pkg_resources import WorkingSet, DistributionNotFound
        working_set = WorkingSet()
        working_set.require('django_nose')
    except ImportError:
        print('setuptools not installed.  Weird.')
    except DistributionNotFound:
        print("django-nose not installed.  You'd like it.")
    else:
        config['INSTALLED_APPS'].append('django_nose')
        config['TEST_RUNNER'] = 'django_nose.NoseTestSuiteRunner'

    # Optionally update configuration
    try:
        import t_overrides
    except ImportError:
        pass
    else:
        config = t_overrides.update(config)

    return config
Example #5
0
def main(*paths):
    # Dynamically configure the Django settings with the minimum necessary to
    # get Django running tests
    config = {
        'INSTALLED_APPS': ['multigtfs'],
        'TEST_RUNNER': 'django.test.simple.DjangoTestSuiteRunner',
        'DATABASE_ENGINE': 'django.contrib.gis.db.backends.spatialite',
        'DATABASES': {
            'default': {
                'ENGINE': 'django.contrib.gis.db.backends.spatialite',
            }
        },
        'DEBUG': True,
        'TEMPLATE_DEBUG': True
    }

    try:
        import south
    except ImportError:
        pass
    else:
        assert south  # flake8 be quiet
        config['INSTALLED_APPS'].insert(0, 'south')

    # If django-nose is installed, use it
    # You can do things like ./run_tests.py --with-coverage
    try:
        from pkg_resources import WorkingSet, DistributionNotFound
        working_set = WorkingSet()
        working_set.require('django_nose')
    except ImportError:
        print('setuptools not installed.  Weird.')
    except DistributionNotFound:
        print("django-nose not installed.  You'd like it.")
    else:
        config['INSTALLED_APPS'].append('django_nose')
        config['TEST_RUNNER'] = 'django_nose.NoseTestSuiteRunner'

    # Optionally update configuration
    try:
        import t_overrides
    except ImportError:
        pass
    else:
        config = t_overrides.update(config)

    settings.configure(**config)

    from django.core import management
    failures = management.call_command('test', *paths)
    sys.exit(failures)
Example #6
0
def main(pkgList):
    working_set = WorkingSet()
    for pkgName, pkgVersion in pkgList.iteritems():
        try:
            depends = working_set.require(pkgName)
        except DistributionNotFound:
            import os
            import urllib2
            print "\n -- Library " + pkgName + " needs to be installed --\n"
            # Prompt for user decision if a package requires installation
            allow = raw_input(" May I install the above library? ([y]/n): ")
            if allow.upper() == "N"  or allow.upper() == "NO":
                sys.exit("\n -- Please install package " + pkgName +
                         " manually. Aborting. --\n")
            else:
                try:
                    response = urllib2.urlopen('http://www.google.com', timeout=20)
                    os.system("easy_install-2.7 --user " + pkgName + "==" + pkgVersion)
                    # Important: After installation via easy_install, I must 
                    # restart the script for certain new modules (i.e. those 
                    # installed via egg,like dendropy) to be properly loaded
                    os.execv(__file__, sys.argv)
                    # TFLs, while nicer, fails because easy_install must be
                    # run as superuser
                    #   from setuptools.command.easy_install import main as install
                    #   install([pkg])
                except urllib2.URLError as err:
                    sys.exit("\n -- Please connect to the internet. Aborting. --\n")
        # Eventually, import the module
        exec("import " + pkgName)
        ## Alternative: modules = map(__import__, pkgList)

    ## Completion notice
    print "\n -- P2C2M: Installation of Python libraries complete --\n"
def sys_install_packages(installed_packages,requirements):
    packages=[]
    with open(requirements, "rt") as f:
        for line in f:
            l = line.strip()
            package = l.split(',')
            package=package[0]
            packages.append(package)

    for i in packages:
        if i in installed_packages:
            continue
            log.info("The %s package is already installed" % (i))
        if i not in installed_packages:
            working_set = WorkingSet()
            try:
                dep = working_set.require('paramiko>=1.0')
            except DistributionNotFound:
                pass

            whoami=os.getlogin()
            if whoami =='root':
                installPackage=install([i])
                log.info("Newlly installation of %s is sucessfully done"% (installPackage))
            if whoami !='root':
                try:
                    installPackage=subprocess.check_call(["pip", "install","--user", i])
                    log.info("Newlly installation of %s is sucessfully done"% (installPackage))
                except:
                    try:
                        installPackage=subprocess.check_call(["pip3", "install","--user", i])
                        log.info("Newlly installation of %s is sucessfully done"% (installPackage))
                    except Exception as e:
                        e = sys.exc_info()
                        log.error("the above error occured while installing %s package"% (e))
def package_installation(logger):
    try:
        reqs = subprocess.check_output([sys.executable, '-m', 'pip', 'freeze'])
    except:
        try:
            reqs = subprocess.check_output(
                [sys.executable, '-m', 'pip3', 'freeze'])
        except:
            print(
                "Please ensure that pip or pip3 is installed on your laptop and redo the setup"
            )
    installed_packages = [r.decode().split('==')[0] for r in reqs.split()]

    config = conf_reader.get_config()
    requirements = config.get("requirements", None)

    print('packages execution started...')
    packages = []

    try:
        with open(requirements, "rt") as f:
            for line in f:
                l = line.strip()
                package = l.split(',')
                package = package[0]
                packages.append(package)

        for i in packages:
            if i not in installed_packages:
                working_set = WorkingSet()
                try:
                    dep = working_set.require('paramiko>=1.0')
                except DistributionNotFound:
                    pass
                whoami = os.getlogin()
                if whoami == 'root':
                    install([i])
                if whoami != 'root':
                    try:
                        subprocess.check_call(["pip", "install", "--user", i])
                    except:
                        try:
                            subprocess.check_call(
                                ["pip3", "install", "--user", i])
                        except:
                            print(
                                "Check whether this user has admin privileges for installing package"
                            )

    except Exception as e:
        logger.exception(
            'ERROR:: Some issue in reading the Config...check config_reader.py script in bin Folder....'
        )
        raise e
Example #9
0
def checkApps(apps=[]):
    working_set = WorkingSet()
    for app in apps:
        manifest = getAppManifest(app)
        if manifest:
            for dependency in manifest["externalDependencies"]:
                try:
                    dep = working_set.require(dependency)
                except DistributionNotFound:
                    from setuptools.command.easy_install import main as install
                    try:
                        install([dependency])
                    except Exception as e:
                        print e
def attempt_pkg_install(pkg):
    msg("This tool requires the {0} package to be installed. Attempting installation..."
        .format(pkg))
    from pkg_resources import WorkingSet, DistributionNotFound
    working_set = WorkingSet()
    try:
        dep = working_set.require(pkg)
    except DistributionNotFound:
        try:
            from setuptools.command.easy_install import main as install
            install([pkg])
        except:
            msg("This tool was unable to find or install a required dependency: {0}"
                .format(pkg))
            exit
 def go(self):
     working_set = WorkingSet()
     for pkgName in self.pkgList:
         try:
             depends = working_set.require(pkgName)
         except DistributionNotFound:
             from setuptools.command.easy_install import main as install
             import urllib2
             print("\n  Library '" + pkgName + "' needs to be installed.")
             allow = input("  May I install the above library? ([y]/n): ")  # Prompt for user decision if a package requires installation
             allow = allow.upper()
             if allow == "N" or allow == "NO":
                 sys.exit("\n  ERROR: Please install package '" + pkgName + "' manually.\n")
             else:
                 try:
                     response = urllib2.urlopen("http://www.python.org/", timeout=10)
                 except urllib2.URLError as err:
                     sys.exit("\n  ERROR: No internet connection available.\n")
             try:
                 install(["--user", pkgName])                                # Make certain to use the user flag
                 # ALTERNATIVE: os.system("easy_install-2.7 --user " + pkgName + "==" + pkgVersion)
                 print("\n  Library '" + pkgName + "' installed successfully.")
                 # ALTERNATIVE: print "\n  Library '" + pkgName + "v." + pkgVersion + "' installed successfully."
             except:
                 import os
                 if sys.platform == "linux" or sys.platform == "linux2":
                     if isExe("pip2.7"):
                         os.system("pip2.7 install " + pkgName + " --user")
                     else:
                         ("\n  ERROR: Python setuptools inaccessible.\n")
                 elif sys.platform == "darwin":
                     if isExe("pip2.7"):
                         os.system("pip2.7 install " + pkgName + " --user")
                     else:
                         ("\n  ERROR: Python setuptools inaccessible.\n")
                 elif sys.platform == "win32":
                     if isExe("pip2.7.exe"):
                         os.system("pip2.7.exe install " + pkgName)
                     else:
                         ("\n  ERROR: Python setuptools inaccessible.\n")
             try:
                 exec("import " + pkgName)
             except ImportError:
                 sys.exit("\n  Please restart this script.\n")         # After installation via easy_install, Python must be restarted for certain new modules to be properly loaded
Example #12
0
def initialSetup():
    from pkg_resources import WorkingSet, DistributionNotFound
    workingSet = WorkingSet()
    requirements = ['psutil']
    print 'Checking dependencies......'
    for requirement in requirements:
        try:
            dep = workingSet.require(requirement)
            print 'Dependency found....'
            print 'Countinuing to the program...'
        except DistributionNotFound:
            print 'Installing dependencies...'
            from setuptools.command.easy_install import main as install
            try:
                install([requirement])
                print 'Dependency installed...'
                print 'Continuing....'
            except Exception:
                print 'Coudn\'t install dependencies...'
Example #13
0
def main(pkgList):
    working_set = WorkingSet()
    for pkgName, pkgVersion in pkgList.iteritems():
        try:
            depends = working_set.require(pkgName)
        except DistributionNotFound:
            import os
            import urllib2
            print "\n -- Library " + pkgName + " needs to be installed --\n"
            # Prompt for user decision if a package requires installation
            allow = raw_input(" May I install the above library? ([y]/n): ")
            if allow.upper() == "N" or allow.upper() == "NO":
                sys.exit("\n -- Please install package " + pkgName +
                         " manually. Aborting. --\n")
            else:
                try:
                    response = urllib2.urlopen('http://www.google.com',
                                               timeout=20)
                    os.system("easy_install-2.7 --user " + pkgName + "==" +
                              pkgVersion)
                    # Important: After installation via easy_install, I must
                    # restart the script for certain new modules (i.e. those
                    # installed via egg,like dendropy) to be properly loaded
                    os.execv(__file__, sys.argv)
                    # TFLs, while nicer, fails because easy_install must be
                    # run as superuser
                    #   from setuptools.command.easy_install import main as install
                    #   install([pkg])
                except urllib2.URLError as err:
                    sys.exit(
                        "\n -- Please connect to the internet. Aborting. --\n")
        # Eventually, import the module
        exec("import " + pkgName)
        ## Alternative: modules = map(__import__, pkgList)

    ## Completion notice
    print "\n -- P2C2M: Installation of Python libraries complete --\n"
Example #14
0
def main():
	"""script for automatic installation of steam on crunchbang """
	working_set = WorkingSet()
	# Detecting if module is installed
	try:
	    dep = working_set.require('wget>=1.0')
	except DistributionNotFound:
		print "missing modules. need wget to work. Try 'easy_install wget'"
		
	is_64bits = sys.maxsize > 2**32
	steam="http://media.steampowered.com/client/installer/steam.deb"
	xkit="http://mirrors.us.kernel.org/ubuntu//pool/main/x/x-kit/python-xkit_0.4.2.3build1_all.deb"
	jockey="http://mirrors.us.kernel.org/ubuntu//pool/main/j/jockey/jockey-common_0.9.7-0ubuntu7_all.deb"
	
	steamf=wget.download(steam)
	print 
	xkitf=wget.download(xkit)
	print 
	jockeyf=wget.download(jockey)
	print 
	time.sleep(2)
	
	os.system("sudo dpkg --install " + xkitf)
	os.system("sudo dpkg --install " + jockeyf)

	if is_64bits:
		os.system("sudo dpkg --add-architecture i386")
	
	os.system('echo "##remove this and the line underneath:" | sudo tee -a /etc/apt/sources.list ')
	os.system('echo "deb http://ftp.de.debian.org/debian sid main" | sudo tee -a /etc/apt/sources.list ')
	os.system("sudo apt-get update")
	os.system("sudo apt-get install libc6")
	os.system("sudo dpkg --install " + steamf)
	os.system("steam &")
	os.system("sudo geany /etc/apt/sources.list")
	
	return 0
Example #15
0
#!/usr/bin/env python

from setuptools import setup
from pkg_resources import WorkingSet, DistributionNotFound
working_set = WorkingSet()

requirements = ["watchdog>=0.8.0", 'jinja2>=2.8', 'markdown>=2.6.0']

try:
    working_set.require('paramiko>=1.10.0')
except DistributionNotFound:
    reqirements.append('paramiko>=1.10.0')

setup(
    name='FolderSync',
    version='0.1.0',
    description='Copy and modify directory content in various ways ',
    author='Luka Cehovin',
    author_email='*****@*****.**',
    url='https://github.com/lukacu/python-foldersync/',
    packages=['foldersync', 'foldersync.storage', 'foldersync.processors'],
    scripts=["bin/folderwatch", "bin/folderexport"],
    install_requires=requirements,
)
#!/usr/bin/env python

from pkg_resources import WorkingSet, DistributionNotFound, VersionConflict, UnknownExtra, ExtractionError
import os

working_set = WorkingSet()
requirements = open('requirements.txt', 'r')

for line in requirements:
    try:
        working_set.require(line)
    except DistributionNotFound:
        print "Module %s Not Installed!" % line
    except VersionConflict:
        print "Module %s Version is not correct!" % line
    except ExtractionError:
        print "Module %s Extraction error is foudn " % line
    else:
        print "Module %s is installed" % line.strip()
Example #17
0
from pkg_resources import WorkingSet, DistributionNotFound
from setuptools.command.easy_install import main as installer
import platform
import subprocess

workingSet = WorkingSet()
dependencies = {'pynput': '1.0.6', 'pyscreeze': '0.1.11', 'playsound': '1.2.1'}

try:
    for key, value in dependencies.items():
        dep = workingSet.require('{}>={}'.format(key, value))
except:
    try:
        if platform.system() == 'Windows':
            installer(['{}>={}'.format(key, value)])
        elif platform.system() == 'Linux':
            installer(['{}>={}'.format(key,
                                       value)])  # convert this to pip later
        print('{} {} has been installed successfully'.format(key, value))
    except:
        print('Dependecy installation error when installing {}>={}'.format(
            key, value))
        pass
    pass
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
}

SIMSERVER_WORKING_DIR = '/home/jgmize/simserver'

if 'test' in sys.argv:
    TEST_RUNNER = 'django.test.simple.DjangoTestSuiteRunner'
    try:
        from pkg_resources import WorkingSet, DistributionNotFound
        working_set = WorkingSet()
        working_set.require('django_nose')
    except ImportError:
        print 'setuptools not installed.  Weird.'
    except DistributionNotFound:
        print "django-nose not installed.  You'd like it."
    else:
        INSTALLED_APPS.append('django_nose')
        TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
        }
    }
    DEBUG = True
    TEMPLATE_DEBUG = True
Example #19
0
requirements = config.get("requirements", None)
# required packages for executing the program is collecting from ../lib/requirement.txt then installing the package
# requirements=["selenium","pandas","mysql-connector-python","times","datetime","beautifulsoup4"]
packages = []
with open(requirements, "rt") as f:
    for line in f:
        l = line.strip()
        package = l.split(',')
        package = package[0]
        packages.append(package)

for i in packages:
    if i not in installed_packages:
        working_set = WorkingSet()
        try:
            dep = working_set.require('paramiko>=1.0')
        except DistributionNotFound:
            pass
        whoami = os.getlogin()
        if whoami == 'root':
            install([i])
        if whoami != 'root':
            try:
                subprocess.check_call(["pip", "install", "--user", i])
            except:
                try:
                    subprocess.check_call(["pip3", "install", "--user", i])
                except:
                    print(
                        "Check whether this user has admin privileges for installing package"
                    )
Example #20
0
# Ensure cirros 0.3.3 is the image in tempest
# Ensure that allow overlapping tenants is set to false?
# tempest.conf is configured properly, and tenants are clean

import glanceclient.v2.client as glclient
import keystoneclient.v2_0.client as ksclient
import novaclient.v2.client as nvclient
import os
import pip

from pkg_resources import WorkingSet, DistributionNotFound

try:
    working_set = WorkingSet()
    dep = working_set.require('SimpleConfigParser')
except DistributionNotFound:
    pip.main(['install', 'SimpleConfigParser'])

from simpleconfigparser import simpleconfigparser
from tempest.common import cred_provider
from tempest import clients
from tempest import config

CONF = config.CONF
image_ref = None
tenant = None


def main():
    credentials = cred_provider.get_configured_credentials('identity_admin')
    network_client, image_client, glance_client, nova_client = set_context(credentials)
Example #21
0
__import__('pkg_resources').declare_namespace(__name__)

# encoding: utf-8
__all__ = ['abstractmapper', 'ghrsstncfile', 'gribfile', 'hdffile',
    'ncfile', 'qscathdffile', 'saralncfile', 'sopranoncfile', 'urlseries',
    'ascatifrncfile']

from pkg_resources import WorkingSet, DistributionNotFound
import logging

# Import what mappers are avaialble.
packages = WorkingSet() 

try:
    packages.require('netCDF4')
    # from . import ghrsstncfile
    # from . import ncfile
    # from . import saralncfile
    # from . import sopranoncfile
    # from . import ascatifrncfile
except DistributionNotFound, exception:
    logging.warning('Python netCDF4 package is required for netCDF. ' 
        'No netCDF compatable modules are avaialble on this cerbere instance')
except ImportError:
    logging.exception('A netCDF mapper failed to load, and is unavailable:')
    
try:
    packages.require('pygrib')
    # from . import gribfile
except DistributionNotFound, exception:
    logging.warning('Python pygrib package is required for GRIB. ' 
 if ru_python.upper() == 'Y':
     print('Installing packages...')
     time.sleep(1)
     loading(2)
     clear()
     print('###########################################################################')
     print('# All Packages that are installed are shown below this                    #')
     print('###########################################################################')
     print (s.modules.keys())
     print('###########################################################################')
     print('# All Packages that are installed are shown above this                    #')
     print('###########################################################################')
     continu()
     ru_pythonn = False
     try:
         dep = working_set.require('pyicloud')
     except DistributionNotFound:
         from setuptools.command.easy_install import main as install
         install(['pyicloud'])
         pass
     time.sleep(1)
     clear()
     print('RETURNING TO SETUP')
     time.sleep(1)
 elif ru_pythonn.upper() == 'N':
     clear()
     print('Returning to setup!')
     time.sleep(1)
     ru_pythonn = False
 else:
     clear()
Example #23
0
# -*- coding: utf-8 -*-

import subprocess

from pkg_resources import WorkingSet, DistributionNotFound
from setuptools.command.easy_install import main as install

working_set = WorkingSet()

# Detecting if module is installed
try:
    dep = working_set.require('nb_pdf_template')

except DistributionNotFound:
    print("Starting one-time install of templates for your PDF export.")
    install(['nb_pdf_template'])
    subprocess.Popen(["python", "-m", "nb_pdf_template.install", "--minted"])
from pkg_resources import WorkingSet , DistributionNotFound
working_set = WorkingSet()

# Printing all installed modules
print tuple(working_set)

# Detecting if module is installed
try:
    dep = working_set.require('paramiko>=1.0')
except DistributionNotFound:
    pass

# Installing it (anyone knows a better way?)
from setuptools.command.easy_install import main as install
install(['django>=1.2'])
Example #25
0
#!/usr/bin/python
from __future__ import division
from pkg_resources import WorkingSet, DistributionNotFound
import sys

working_set = WorkingSet()

# Printing all installed modules
# print tuple(working_set)

# Detecting if module is installed
dependency_found = True
try:
    dep = working_set.require('Jinja2')
except DistributionNotFound:
    dependency_found = False
    pass

if not dependency_found:
    try:
        # Installing it (anyone knows a better way?)
        from setuptools.command.easy_install import main as install

        install(['Jinja2'])
        print("run again as normal user to process results")
    except DistributionNotFound:
        print("run this script as sudo to install a missing template engine")
        pass
    sys.exit(0)

import csv
#!/usr/bin/env python 

from pkg_resources import WorkingSet , DistributionNotFound, VersionConflict, UnknownExtra, ExtractionError
import os

working_set = WorkingSet()
requirements = open('requirements.txt', 'r')

for line in requirements:
    try:
        working_set.require(line)
    except DistributionNotFound:
        print "Module %s Not Installed!" % line
    except VersionConflict:
        print "Module %s Version is not correct!" % line
    except ExtractionError:
        print "Module %s Extraction error is foudn " % line
    else:
        print "Module %s is installed" % line.strip()