Skip to content

Commit

Permalink
updated setup for pip install and committing LICENSE agreement
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristina Garcia committed Jan 15, 2020
1 parent 6240da8 commit 152e75a
Show file tree
Hide file tree
Showing 2 changed files with 176 additions and 143 deletions.
126 changes: 126 additions & 0 deletions LICENSE
@@ -0,0 +1,126 @@
The MIT License (MIT)

Copyright (c) 2016-2019 Carbon Black

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.



This software was based on cbapi2, whose license is included below:

Copyright (c) 2015 Red Canary

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


This software contains a file, win32/Lib/winerror.py, from the pywin32 module
with the following license:

Copyright (c) 1994-2008, Mark Hammond
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.

Neither name of Mark Hammond nor the name of contributors may be used
to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


This software contains a copy of py-lru-cache, with the following license:

Copyright (c) 2012, Chris Stucchio
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


This software contains a copy of six, with the following license:

Copyright (c) 2010-2015 Benjamin Peterson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
193 changes: 50 additions & 143 deletions setup.py
@@ -1,124 +1,19 @@
from distutils.core import setup
from distutils.core import Command
from distutils.command.bdist_rpm import bdist_rpm

from distutils.file_util import write_file
from distutils.util import change_root, convert_path
"""
cb-defense-syslog
"""

from setuptools import setup
import sys
import os
from subprocess import call


class bdist_binaryrpm(bdist_rpm):
description = "create a Cb Open Source Binary RPM distribution"

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
sdist = self.reinitialize_command('sdist')
self.run_command('sdist')
source = sdist.get_archive_files()[0]
self.copy_file(source, os.path.join(os.getenv("HOME"), "rpmbuild", "SOURCES"))

# Lots TODO here: generate spec file on demand from the rest of this setup.py file, for starters...
# self._make_spec_file()
call(['rpmbuild', '-bb', '%s.spec' % self.distribution.get_name()])


"""This install_cb plugin will install all data files associated with the
tool as well as the pyinstaller-compiled single binary scripts so that
they can be packaged together in a binary RPM."""
class install_cb(Command):
description = "install binary distribution files"

user_options = [
('install-dir=', 'd',
"base directory for installing data files "
"(default: installation base dir)"),
('root=', None,
"install everything relative to this alternate root directory"),
('force', 'f', "force installation (overwrite existing files)"),
('record=', None,
"filename in which to record list of installed files"),
]

boolean_options = ['force']

def initialize_options(self):
self.install_dir = None
self.outfiles = []
self.root = None
self.force = 0
self.data_files = self.distribution.data_files
self.warn_dir = 1
self.record = None

def finalize_options(self):
self.set_undefined_options('install',
('install_data', 'install_dir'),
('root', 'root'),
('force', 'force'),
)

def run(self):
for f in self.data_files:
if isinstance(f, str):
# don't copy files without path information
pass
else:
# it's a tuple with path to install to and a list of files
dir = convert_path(f[0])
if not os.path.isabs(dir):
dir = os.path.join(self.install_dir, dir)
elif self.root:
dir = change_root(self.root, dir)
self.mkpath(dir)

if f[1] == []:
# If there are no files listed, the user must be
# trying to create an empty directory, so add the
# directory to the list of output files.
self.outfiles.append(dir)
else:
# Copy files, adding them to the list of output files.
for data in f[1]:
data = convert_path(data)
(out, _) = self.copy_file(data, dir)
self.outfiles.append(out)

for scriptname in scripts.keys():
pathname = scripts[scriptname]['dest']
dir = convert_path(pathname)
dir = os.path.dirname(dir)
dir = change_root(self.root, dir)
self.mkpath(dir)

data = os.path.join('dist', scriptname)
(out, _) = self.copy_file(data, dir, preserve_mode=True)
self.outfiles.append(out)

if self.record:
outputs = self.get_outputs()
if self.root: # strip any package prefix
root_len = len(self.root)
for counter in xrange(len(outputs)):
outputs[counter] = outputs[counter][root_len:]
self.execute(write_file,
(self.record, outputs),
"writing list of installed files to '%s'" %
self.record)


def get_inputs(self):
return self.data_files or []

def get_outputs(self):
return self.outfiles

install_requires=[
'Jinja2>=2.8.1',
'MarkupSafe==0.23',
'requests>=2.20.0',
'flask==0.12.4',
'six==1.12.0'
]

def get_data_files(rootdir):
# automatically build list of (dir, [file1, file2, ...],)
Expand All @@ -132,7 +27,19 @@ def get_data_files(rootdir):

return results

def create_store_directory():
store_forwarder_dir = 'root/usr/share/cb/integrations/cb-defense-syslog'

try:
os.mkdir(store_forwarder_dir)
except OSError:
print("Creation of the directory %s failed" % store_forwarder_dir)
else:
print("Successfully created the directory %s " % store_forwarder_dir)


data_files = get_data_files("root")
create_store_directory()
data_files.append('cb-defense-syslog.spec')
data_files.append('cb_defense_syslog.py')
scripts = {
Expand All @@ -143,31 +50,31 @@ def get_data_files(rootdir):
}

setup(
name='python-cb-defense-syslog',
version='2.0',
packages=[],
url='https://github.com/carbonblack/cb-defense-syslog-tls',
license='MIT',
author='Carbon Black Developer Network',
author_email='cb-developer-network@vmware.com',
description=
name='python-cb-defense-syslog',
version='2.0',
packages=[],
url='https://github.com/carbonblack/cb-defense-syslog-tls',
license='MIT',
author='Carbon Black Developer Network',
author_email='cb-developer-network@vmware.com',
description=
'Connector for Cb Defense to send notifications to a tcp+tls host',
data_files=data_files,
classifiers=[
'Development Status :: 4 - Beta',

# Indicate who your project is intended for
'Intended Audience :: Developers',

# Pick your license as you wish (should match "license" above)
'License :: OSI Approved :: MIT License',

# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
],
keywords='carbonblack',
cmdclass={'install_cb': install_cb, 'bdist_binaryrpm': bdist_binaryrpm}
data_files=data_files,
install_requires=install_requires,
classifiers=[
'Development Status :: 4 - Beta',

# Indicate who your project is intended for
'Intended Audience :: Developers',

# Pick your license as you wish (should match "license" above)
'License :: OSI Approved :: MIT License',

# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
],
keywords='carbonblack'
)

0 comments on commit 152e75a

Please sign in to comment.