Esempio n. 1
0
 def saveDimValue(self, val):
     if (self.dimCacheFilePath is not ""):
         try:
             file = open(self.dimCacheFilePath, "w+")
             file.write("%s" % (str(val)))
             file.close()
         except:
             MyLog.e(self.TAG, "Error:6011")
Esempio n. 2
0
 def setDim(self):
     # Change brightness
     try:
         cmd_value = "xrandr --output %s --brightness %s" % (self.display1,
                                                             self.dimValue)
         subprocess.check_output(cmd_value, shell=True)
         cmd_value = "xrandr --output %s --brightness %s" % (self.display2,
                                                             self.dimValue)
         subprocess.check_output(cmd_value, shell=True)
     except:
         MyLog.e(self.TAG, "Error:6014")
         self.setAvailable(False)
 def setBrightness(self, brightness):
     self.currentBrightness = brightness
     try:
         subprocess.call([
             'pkexec',
             '/usr/lib/gnome-settings-daemon/gsd-backlight-helper',
             '--set-brightness',
             "%s" % self.currentBrightness
         ])
     except:
         MyLog.e(self.TAG, "Error:6033")
         self.setAvailable(False)
Esempio n. 4
0
    def assignDisplays(self):
        # assigns display name

        try:
            self.displays = self.detectDisplayDevices()
            self.noOfDisplays = len(self.displays)
            self.noOfConnectedDev = self.noOfDisplays
            if self.noOfDisplays is 1:
                self.display1 = self.displays[0]
            elif self.noOfDisplays is 2:
                self.display1 = self.displays[0]
                self.display2 = self.displays[1]
        except:
            MyLog.e(self.TAG, "Error:6013")
            self.setAvailable(False)
    def getCurrentBrightnessFromHelper(self):
        try:
            p = subprocess.Popen([
                'pkexec',
                '/usr/lib/gnome-settings-daemon/gsd-backlight-helper',
                '--get-brightness'
            ],
                                 stdout=subprocess.PIPE)
            comm = p.communicate()[0]
            self.currentBrightness = int(comm)
        except:
            MyLog.e(self.TAG, "Error:6031")
            return self.setAvailable(False)

        return self.currentBrightness
Esempio n. 6
0
	def run(self):
		mylog = MyLog('/home/pi/Documents/DealProject/log/dealdaemon.log')
		dealsea = Dealsea()
		slickdeals = Slickdeals()
		tagging = Tagging()
		ppom = Ppomppu()
		sendManualTag = ManualTag()
		clien = Clien()
		while True:
			dealsea.run()
			logging.info('***************************DEALSEA DONE******************************')
			slickdeals.run()
			logging.info('***************************SLICKDEALS DONE******************************')
			ppom.run()
			logging.info('***************************PPOMPPU DONE******************************')
			clien.run()
			logging.info('***************************CLIEN DONE******************************')
			try:
				logging.info('***************************tagging started***************************')
				for index in range(8):
					if tagging.run() <= 0:
						break
					else:
						logging.info('***************************tagging again***************************')
				logging.info('***************************tagging ended***************************')
				# sendManualTag.run()
			except Exception as e:
				logging.exception(e)
			
			time.sleep(60*5) # 20 minutes
Esempio n. 7
0
    def retriveDimValue(self):
        val = "1"
        try:
            if (self.dimCacheFilePath is not ""):
                if (os.path.isfile(self.dimCacheFilePath)):
                    file = open(self.dimCacheFilePath, "r+")
                    file.seek(0)
                    val = file.read()
                    file.close()
                    if (val == None):
                        val = "1"
                    if (val == ""):
                        val = "1"
        except:
            MyLog.e(self.TAG, "Error:6012")

        return float("%s" % (val))
Esempio n. 8
0
    def __init__(self):
        MyLog.d(self.TAG, "init")

        # about files
        try:
            self.home_dir = os.path.expanduser("~")
            self.dir_path = os.path.dirname(os.path.realpath(__file__))
            self.ubrightnesscontroller_path = self.home_dir + \
                '/.config/budgie-advanced-brightness-controller'
            self.makeDirIfNotExist(self.ubrightnesscontroller_path)
            self.dimCacheFilePath = self.ubrightnesscontroller_path + "/dim.txt"
        except:
            MyLog.e(self.TAG, "Error:6010")

        # about displays
        self.display1 = None
        self.display2 = None
        self.noOfConnectedDev = 0
        self.assignDisplays()

        # update
        self.update(self.retriveDimValue())
Esempio n. 9
0
    def run(self):
        mylog = MyLog('/home/pi/Documents/DealProject/log/senddeal.log')
        config = {}

        try:
            with open('/home/pi/Documents/DealProject/config.json', 'r') as f:
                config = json.load(f)
        except Exception as e:
            logging.exception(e)

        self.bot = telepot.Bot(config['manual_tag_bot'])
        self.engine = create_engine(config['mysql'])

        while True:
            self.runSendMessage()
            logging.info('sleep')
            time.sleep(60)
Esempio n. 10
0
 def setAvailable(self, b):
     self.isAvailable = b
     if (not self.isAvailable):
         MyLog.i(self.TAG, "Dim is not available")
 def setAvailable(self, b):
     self.isAvailable = b
     if (not self.isAvailable):
         MyLog.i(self.TAG, "No backlight detected")
    def __init__(self):
        MyLog.d(self.TAG, "init")

        self.maxBrightness = self.getMaxBrightnessFromHelper()
        self.currentBrightness = self.getCurrentBrightnessFromHelper()
Esempio n. 13
0
import sys
import re
import time
from MyLog import MyLog
from genie.testbed import load
LOG = MyLog('junosPyEz.py', 'DEBUG')
import os


class ciscoPyAts(object):
    def __init__(self):
        print('Object instantial')

    def connect_to_device(self, inputFile, device):
        dirPath = os.path.dirname(os.path.abspath(__file__))
        dstFolder = os.path.dirname(os.path.abspath(dirPath))
        filepath = dstFolder + "/InputFiles/" + inputFile
        tb = load(filepath)
        try:
            dev = tb.devices[device]
            dev.connect()
        except:
            LOG.info("Cannot connect to device: {0}".format(err))
            sys.exit(1)
        return dev

    def disconnect_device(self, dev):
        dev.disconnect()

    def run_show_command(self, dev, command):
        response = dev.execute(command)