Skip to content

Commit

Permalink
Merge branch 'sysinfo' of github.com:kiok46/plyer into kiok46-sysinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
akshayaurora committed Mar 22, 2024
2 parents 47fbce1 + 326a65b commit 8b39f7b
Show file tree
Hide file tree
Showing 14 changed files with 1,130 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ bin
*.DS_Store

# Coverage
.coverage
.coverage
80 changes: 80 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
Plyer
=====

Plyer is a platform-independent api to use features commonly found on various
platforms, notably mobile ones, in Python.

How
---

Plyer tries not to reinvent the wheel, and will call for external libraries to
implement the api in the easiest way, depending on the current platform.

- on python-for-android, pyjnius is used
- on kivy-ios, pyobjus is used
- on windows/mac/linux, commonly found libraries and programs will be used

Supported APIs
--------------

================================== ======= === ======= ==== =====
Platform Android iOS Windows OS X Linux
================================== ======= === ======= ==== =====
Accelerometer X X X X
Call X X
Camera (taking picture) X X
GPS X X
Notifications X X X X
Text to speech X X X X X
Email (open mail client) X X X X X
Vibrator X X
Sms (send messages) X X
Sysinfo X X X X X
Compass X X
Unique ID X X X X X
Gyroscope X X
Battery X X X X X
Native file chooser X X X
Orientation X
Audio recording X
Flash X X
================================== ======= === ======= ==== =====

Support
-------

If you need assistance, you can ask for help on our mailing list:

* User Group : https://groups.google.com/group/kivy-users
* Email : kivy-users@googlegroups.com

We also have an IRC channel:

* Server : irc.freenode.net
* Port : 6667, 6697 (SSL only)
* Channel : #kivy

Contributing
------------

We love pull requests and discussing novel ideas. Check out our
`contribution guide <http://kivy.org/docs/contribute.html>`_ and
feel free to improve Plyer.

The following mailing list and IRC channel are used exclusively for
discussions about developing the Kivy framework and its sister projects:

* Dev Group : https://groups.google.com/group/kivy-dev
* Email : kivy-dev@googlegroups.com

IRC channel:

* Server : irc.freenode.net
* Port : 6667, 6697 (SSL only)
* Channel : #kivy-dev

License
-------

Plyer is released under the terms of the MIT License. Please refer to the
LICENSE file.
173 changes: 173 additions & 0 deletions examples/sysinfo/buildozer.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
[app]

# (str) Title of your application
title = Plyer Sysinfo Example

# (str) Package name
package.name = sysinfoexample

# (str) Package domain (needed for android/ios packaging)
package.domain = org.test

# (str) Source code where the main.py live
source.dir = .

# (list) Source files to include (let empty to include all the files)
source.include_exts = py,png,jpg,kv,atlas

# (list) Source files to exclude (let empty to not exclude anything)
#source.exclude_exts = spec

# (list) List of directory to exclude (let empty to not exclude anything)
#source.exclude_dirs = tests, bin

# (list) List of exclusions using pattern matching
#source.exclude_patterns = license,images/*/*.jpg

# (str) Application versioning (method 1)
# version.regex = __version__ = '(.*)'
# version.filename = %(source.dir)s/main.py

# (str) Application versioning (method 2)
version = 1.0

# (list) Application requirements
requirements = kivy, plyer

# (str) Presplash of the application
#presplash.filename = %(source.dir)s/data/presplash.png

# (str) Icon of the application
#icon.filename = %(source.dir)s/data/icon.png

# (str) Supported orientation (one of landscape, portrait or all)
orientation = portrait

# (bool) Indicate if the application should be fullscreen or not
fullscreen = 0


#
# Android specific
#

# (list) Permissions
#android.permissions =

# (int) Android API to use
#android.api = 14

# (int) Minimum API required (8 = Android 2.2 devices)
#android.minapi = 8

# (int) Android SDK version to use
#android.sdk = 21

# (str) Android NDK version to use
#android.ndk = 9

# (bool) Use --private data storage (True) or --dir public storage (False)
#android.private_storage = True

# (str) Android NDK directory (if empty, it will be automatically downloaded.)
#android.ndk_path =

# (str) Android SDK directory (if empty, it will be automatically downloaded.)
#android.sdk_path =

# (str) Android entry point, default is ok for Kivy-based app
#android.entrypoint = org.renpy.android.PythonActivity

# (list) List of Java .jar files to add to the libs so that pyjnius can access
# their classes. Don't add jars that you do not need, since extra jars can slow
# down the build process. Allows wildcards matching, for example:
# OUYA-ODK/libs/*.jar
#android.add_jars = foo.jar,bar.jar,path/to/more/*.jar

# (list) List of Java files to add to the android project (can be java or a
# directory containing the files)
#android.add_src =

# (str) python-for-android branch to use, if not master, useful to try
# not yet merged features.
#android.branch = master

# (str) OUYA Console category. Should be one of GAME or APP
# If you leave this blank, OUYA support will not be enabled
#android.ouya.category = GAME

# (str) Filename of OUYA Console icon. It must be a 732x412 png image.
#android.ouya.icon.filename = %(source.dir)s/data/ouya_icon.png

# (str) XML file to include as an intent filters in <activity> tag
#android.manifest.intent_filters =

# (list) Android additionnal libraries to copy into libs/armeabi
#android.add_libs_armeabi = libs/android/*.so

# (bool) Indicate whether the screen should stay on
# Don't forget to add the WAKE_LOCK permission if you set this to True
#android.wakelock = False

# (list) Android application meta-data to set (key=value format)
#android.meta_data =

# (list) Android library project to add (will be added in the
# project.properties automatically.)
#android.library_references =

#
# iOS specific
#

# (str) Name of the certificate to use for signing the debug version
# Get a list of available identities: buildozer ios list_identities
#ios.codesign.debug = "iPhone Developer: <lastname> <firstname> (<hexstring>)"

# (str) Name of the certificate to use for signing the release version
#ios.codesign.release = %(ios.codesign.debug)s


[buildozer]

# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output))
log_level = 2


# -----------------------------------------------------------------------------
# List as sections
#
# You can define all the "list" as [section:key].
# Each line will be considered as a option to the list.
# Let's take [app] / source.exclude_patterns.
# Instead of doing:
#
# [app]
# source.exclude_patterns = license,data/audio/*.wav,data/images/original/*
#
# This can be translated into:
#
# [app:source.exclude_patterns]
# license
# data/audio/*.wav
# data/images/original/*
#


# -----------------------------------------------------------------------------
# Profiles
#
# You can extend section / key with a profile
# For example, you want to deploy a demo version of your application without
# HD content. You could first change the title to add "(demo)" in the name
# and extend the excluded directories to remove the HD content.
#
# [app@demo]
# title = My Application (demo)
#
# [app:source.exclude_patterns@demo]
# images/hd/*
#
# Then, invoke the command line with the "demo" profile:
#
# buildozer --profile demo android debug
133 changes: 133 additions & 0 deletions examples/sysinfo/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
from plyer import sysinfo
from kivy.properties import StringProperty, ListProperty


Builder.load_string('''
<SysinfoInterface>:
GridLayout:
cols: 2
Label:
text: "Model"
Label:
text: root.model_
Label:
text: "Platform"
Label:
text: root.platform_
Label:
text: "System"
Label:
text: root.system_
Label:
text: "Processor"
Label:
text: root.processor_
Label:
text: "Version"
Label:
text: root.version_
Label:
text: "Architecture"
Label:
text: root.architecture_
Label:
text: "Device"
Label:
text: root.device_
Label:
text: "Manufacturer"
Label:
text: root.manufacturer_
Label:
text: "Kernel"
Label:
text: root.kernel_
Label:
text: "Storage"
Label:
text: root.storage_
Label:
text: "Screen"
Label:
text: str(root.screen_)
''')


class SysinfoInterface(BoxLayout):

model_ = StringProperty()
platform_ = StringProperty()
system_ = StringProperty()
processor_ = StringProperty()
version_ = StringProperty()
architecture_ = StringProperty()
device_ = StringProperty()
manufacturer_ = StringProperty()
kernel_ = StringProperty()
storage_ = StringProperty()
screen_ = ListProperty()

def __init__(self, **kwargs):
super(SysinfoInterface, self).__init__(**kwargs)
self.update()

def update(self):
self.get_model()
self.get_platform()
self.get_system()
self.get_processor()
self.get_version()
self.get_architecture()
self.get_device_name()
self.get_manufacturer()
self.get_kernel_version()
self.get_storage_info()
self.get_screen_resolution()

def get_model(self):
self.model_ = sysinfo.model_info()

def get_platform(self):
self.platform_ = sysinfo.platform_info()

def get_system(self):
self.system_ = sysinfo.system_name()

def get_processor(self):
self.processor_ = sysinfo.processor_info()

def get_version(self):
temp = sysinfo.version_info()
self.version_ = "{} {} {}".format(temp[0], temp[1], temp[2])

def get_architecture(self):
self.architecture_ = str(sysinfo.architecture_info())

def get_device_name(self):
self.device_ = sysinfo.device_name()

def get_manufacturer(self):
self.manufacturer_ = sysinfo.manufacturer_name()

def get_kernel_version(self):
self.kernel_ = sysinfo.kernel_version()

def get_storage_info(self):
self.storage_ = sysinfo.storage_info()

def get_screen_resolution(self):
self.screen_ = sysinfo.screen_resolution()


class SysinfoApp(App):

def build(self):
return SysinfoInterface()

if __name__ == "__main__":
app = SysinfoApp()
app.run()
Loading

0 comments on commit 8b39f7b

Please sign in to comment.