Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
add support windows OS
Browse files Browse the repository at this point in the history
  • Loading branch information
dynasticorpheus committed Apr 22, 2015
1 parent c1aad10 commit 7e16548
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions gigasetelements-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
gc.disable()

_author_ = 'dynasticorpheus@gmail.com'
_version_ = '1.1.3'
_version_ = '1.1.4'

parser = argparse.ArgumentParser(description='Gigaset Elements - Command-line Interface by dynasticorpheus@gmail.com')
parser.add_argument('-c', '--config', help='fully qualified name of configuration-file', required=False)
Expand Down Expand Up @@ -68,12 +68,19 @@ def exist_module(module, package):
try:
imp.find_module(module)
except ImportError:
log(module + ' not found, try: sudo pip install ' + package, 3)
log(module + ' not found, try: pip install ' + package, 3)
print
sys.exit()
return


def os_type(str):
if os.name == str:
return True
else:
return False


def color(str):
normal = ['ok', 'online', 'closed', 'up_to_date', 'home']
if str in normal:
Expand Down Expand Up @@ -299,7 +306,7 @@ def status():
print('[-] ') + basestation_data[0]['friendly_name'] + ' ' + color(basestation_data[0]['status']) + ' | firmware ' + color(basestation_data[0]['firmware_status'])
for item in basestation_data[0]['sensors']:
try:
print('[-] ') + item['friendly_name'] + ' ' + color(item['status']) + '| firmware ' + color(item['firmware_status']),
print('[-] ') + item['friendly_name'] + ' ' + color(item['status']) + ' | firmware ' + color(item['firmware_status']),
if item['type'] != 'is01':
print '| battery ' + color(item['battery']['state']),
if item['type'] == 'ds02':
Expand All @@ -316,17 +323,22 @@ def status():
print 'Gigaset Elements - Command-line Interface'
print

if args.cronjob is not None:
add_cron(args.cronjob)
if args.status is False and args.events is None:
print
sys.exit()

if args.remove and args.cronjob is None:
remove_cron()
if args.status is False and args.events is None:
print
sys.exit()
if os_type('nt'):
exist_module('colorama', 'colorama')
import colorama
colorama.init()

if os_type('posix'):
if args.cronjob is not None:
add_cron(args.cronjob)
if args.status is False and args.events is None:
print
sys.exit()
if args.remove and args.cronjob is None:
remove_cron()
if args.status is False and args.events is None:
print
sys.exit()

exist_module('requests', 'requests')
import requests
Expand Down

0 comments on commit 7e16548

Please sign in to comment.