initial commit
This commit is contained in:
commit
0b994dcdd3
7 changed files with 230 additions and 0 deletions
74
CODE_OF_CONDUCT.md
Normal file
74
CODE_OF_CONDUCT.md
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
In the interest of fostering an open and welcoming environment, we as
|
||||||
|
contributors and maintainers pledge to making participation in our project and
|
||||||
|
our community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||||
|
nationality, personal appearance, race, religion, or sexual identity and
|
||||||
|
orientation.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to creating a positive environment
|
||||||
|
include:
|
||||||
|
|
||||||
|
* Using welcoming and inclusive language
|
||||||
|
* Being respectful of differing viewpoints and experiences
|
||||||
|
* Gracefully accepting constructive criticism
|
||||||
|
* Focusing on what is best for the community
|
||||||
|
* Showing empathy towards other community members
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||||
|
advances
|
||||||
|
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or electronic
|
||||||
|
address, without explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
## Our Responsibilities
|
||||||
|
|
||||||
|
Project maintainers are responsible for clarifying the standards of acceptable
|
||||||
|
behavior and are expected to take appropriate and fair corrective action in
|
||||||
|
response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit, or
|
||||||
|
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||||
|
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||||
|
permanently any contributor for other behaviors that they deem inappropriate,
|
||||||
|
threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies both within project spaces and in public spaces
|
||||||
|
when an individual is representing the project or its community. Examples of
|
||||||
|
representing a project or community include using an official project e-mail
|
||||||
|
address, posting via an official social media account, or acting as an appointed
|
||||||
|
representative at an online or offline event. Representation of a project may be
|
||||||
|
further defined and clarified by project maintainers.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported by contacting the project team at support@adafruit.com. All
|
||||||
|
complaints will be reviewed and investigated and will result in a response that
|
||||||
|
is deemed necessary and appropriate to the circumstances. The project team is
|
||||||
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||||
|
Further details of specific enforcement policies may be posted separately.
|
||||||
|
|
||||||
|
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||||
|
faith may face temporary or permanent repercussions as determined by other
|
||||||
|
members of the project's leadership.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||||
|
available at [http://contributor-covenant.org/version/1/4][version]
|
||||||
|
|
||||||
|
[homepage]: http://contributor-covenant.org
|
||||||
|
[version]: http://contributor-covenant.org/version/1/4/
|
||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2018 Adafruit Industries
|
||||||
|
|
||||||
|
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.
|
||||||
0
README.rst
Normal file
0
README.rst
Normal file
84
adafruit_platformdetect.py
Normal file
84
adafruit_platformdetect.py
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
# Copyright (c) 2014-2018 Adafruit Industries
|
||||||
|
# Author: Tony DiCola, Limor Fried, Brennen Bearnes
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
"""
|
||||||
|
Attempt to detect the current platform.
|
||||||
|
"""
|
||||||
|
import sys
|
||||||
|
import platform
|
||||||
|
import re
|
||||||
|
|
||||||
|
class PlatformDetect:
|
||||||
|
|
||||||
|
def is_raspberrypi(self):
|
||||||
|
return true
|
||||||
|
|
||||||
|
def is_linux(self):
|
||||||
|
return true
|
||||||
|
|
||||||
|
def pi_revision_code(self):
|
||||||
|
"""Detect the version of the Raspberry Pi. Returns either 1, 2 or
|
||||||
|
None depending on if it's a Raspberry Pi 1 (model A, B, A+, B+),
|
||||||
|
Raspberry Pi 2 (model B+), or not a Raspberry Pi.
|
||||||
|
"""
|
||||||
|
# Check /proc/cpuinfo for the Hardware field value.
|
||||||
|
# 2708 is Pi 1
|
||||||
|
# 2709 is Pi 2
|
||||||
|
# 2835 is Pi 3 (or greater) on 4.9.x kernel
|
||||||
|
# Anything else is not a Pi.
|
||||||
|
with open('/proc/cpuinfo', 'r') as infile:
|
||||||
|
cpuinfo = infile.read()
|
||||||
|
# Match a line like 'Hardware : BCM2709'
|
||||||
|
match = re.search(r'^Hardware\s+:\s+(\w+)$', cpuinfo,
|
||||||
|
flags=re.MULTILINE | re.IGNORECASE)
|
||||||
|
|
||||||
|
if not match:
|
||||||
|
# Couldn't find the hardware, assume it isn't a pi.
|
||||||
|
return None
|
||||||
|
|
||||||
|
if match.group(1) not in ('BCM2708', 'BCM2709', 'BCM2835'):
|
||||||
|
# Something else, not a pi.
|
||||||
|
return None
|
||||||
|
|
||||||
|
rev_match = re.search(r'^Revision\s+:\s+(\w+)$', cpuinfo,
|
||||||
|
flags=re.MULTILINE | re.IGNORECASE)
|
||||||
|
if rev_match:
|
||||||
|
return rev_match.group(1)
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
# 0002 B 1.0 256 MB Egoman
|
||||||
|
# 0003 B 1.0 256 MB Egoman
|
||||||
|
# 0004 B 2.0 256 MB Sony UK
|
||||||
|
# 0005 B 2.0 256 MB Qisda
|
||||||
|
# 0006 B 2.0 256 MB Egoman
|
||||||
|
# 0007 A 2.0 256 MB Egoman
|
||||||
|
# 0008 A 2.0 256 MB Sony UK
|
||||||
|
# 0009 A 2.0 256 MB Qisda
|
||||||
|
# 000d B 2.0 512 MB Egoman
|
||||||
|
# 000e B 2.0 512 MB Sony UK
|
||||||
|
# 000f B 2.0 512 MB Egoman
|
||||||
|
# 0010 B+ 1.0 512 MB Sony UK
|
||||||
|
# 0011 CM1 1.0 512 MB Sony UK
|
||||||
|
# 0012 A+ 1.1 256 MB Sony UK
|
||||||
|
# 0013 B+ 1.2 512 MB Embest
|
||||||
|
# 0014 CM1 1.0 512 MB Embest
|
||||||
|
# 0015 A+ 1.1 256 MB / 512 MB Embest
|
||||||
0
requirements.txt
Executable file
0
requirements.txt
Executable file
46
setup.py
Executable file
46
setup.py
Executable file
|
|
@ -0,0 +1,46 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Note: To use the 'upload' functionality of this file, you must:
|
||||||
|
# $ pip install twine
|
||||||
|
|
||||||
|
import io
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
|
here = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
# Import the README and use it as the long-description.
|
||||||
|
# Note: this will only work if 'README.md' is present in your MANIFEST.in file!
|
||||||
|
with io.open(os.path.join(here, 'README.rst'), encoding='utf-8') as f:
|
||||||
|
long_description = '\n' + f.read()
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name='Adafruit-PlatformDetect',
|
||||||
|
use_scm_version=True,
|
||||||
|
setup_requires=["setuptools_scm"],
|
||||||
|
description='Platform detection for use by libraries like Adafruit-Blinka.',
|
||||||
|
long_description=long_description,
|
||||||
|
long_description_content_type='text/x-rst',
|
||||||
|
author='Adafruit Industries',
|
||||||
|
author_email='circuitpython@adafruit.com',
|
||||||
|
python_requires='>=3.4.0',
|
||||||
|
url='https://github.com/adafruit/Adafruit_Python_PlatformDetect',
|
||||||
|
package_dir={'': 'src'},
|
||||||
|
packages=find_packages("src"),
|
||||||
|
# If your package is a single module, use this instead of 'packages':
|
||||||
|
py_modules=['adafruit_platformdetect'],
|
||||||
|
install_requires=[],
|
||||||
|
license='MIT',
|
||||||
|
classifiers=[
|
||||||
|
# Trove classifiers
|
||||||
|
# Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||||
|
'License :: OSI Approved :: MIT License',
|
||||||
|
'Programming Language :: Python',
|
||||||
|
'Programming Language :: Python :: 3',
|
||||||
|
'Programming Language :: Python :: 3.4',
|
||||||
|
'Programming Language :: Python :: Implementation :: MicroPython',
|
||||||
|
],
|
||||||
|
)
|
||||||
5
test/detect.py
Normal file
5
test/detect.py
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
from adafruit_platformdetect import PlatformDetect
|
||||||
|
|
||||||
|
detect = PlatformDetect()
|
||||||
|
|
||||||
|
print(detect.pi_revision_code())
|
||||||
Loading…
Reference in a new issue