def __init__(self):
     self.logMessage = LogMessage()
     self.const = Constant()
     self.processSensorData = ProcessSensorReading()
     self.processConfigFile = ProcessConfigFile()
     self.GPIOPins = GPIOPin()
     self.bus = smbus.SMBus(1)
Esempio n. 2
0
 def __init__(self):
     self.logMessage = LogMessage()
     self.const = Constant()
     self.sim = SIMOperations()
     self.messages = Message()
     self.processConfigFile = ProcessConfigFile()
     self.processSensorData = ProcessSensorReading()
     self.bus = smbus.SMBus(1)
 def __init__(self):
     self.logMessage = LogMessage()
     self.const = Constant()
     self.sim = SIMOperations()
     self.messages = Message()
     self.processConfigFile = ProcessConfigFile()
     self.messageFilter = MessageFilter()
     self.GPIOPins = GPIOPin()
     if self.const.live:
         self.lcd = RPILCD()
Esempio n. 4
0
 def __init__(self):
     if hasattr(self, '_init'):
         return
     self._init = True
     self.const = Constant()
     self.config_file_path = self.const.conf_dir + "/config.json"
     self.default_config = {
         "version": 1,
         "cache": {
             "value":
             False,
             "default":
             False,
             "describe":
             "A toggle to enable cache function or not. Set value to true to enable it."
         },
         "mpg123_parameters": {
             "value": [],
             "default": [],
             "describe": "The additional parameters when mpg123 start."
         },
         "aria2c_parameters": {
             "value": [],
             "default": [],
             "describe":
             "The additional parameters when aria2c start to download something."
         },
         "music_quality": {
             "value":
             0,
             "default":
             0,
             "describe":
             "Select the quality of the music. May be useful at the terrible network connection. "
             "0 for high quality, 1 for medium and 2 for low."
         }
     }
     self.config = {}
     if not os.path.isfile(self.config_file_path):
         self.generate_config_file()
     try:
         f = file(self.config_file_path, "r")
     except:
         log.debug("Read config file error.")
         return
     try:
         self.config = json.loads(f.read())
     except:
         log.debug("Load config json data failed.")
         return
     f.close()
     if not self.check_version():
         self.save_config_file()
Esempio n. 5
0
 def __init__(self):
     if hasattr(self, '_init'):
         return
     self._init = True
     self.const = Constant()
     self.config = Config()
     self.download_lock = threading.Lock()
     self.check_lock = threading.Lock()
     self.downloading = []
     self.aria2c = None
     self.stop = False
     self.enable = self.config.get_item('cache')
     self.aria2c_parameters = self.config.get_item('aria2c_parameters')
Esempio n. 6
0
    def __init__(self):
        if hasattr(self, "_init"):
            return
        self._init = True

        self.const = Constant()
        self.config = Config()
        self.download_lock = threading.Lock()
        self.check_lock = threading.Lock()
        self.downloading = []
        self.aria2c = None
        self.wget = None
        self.stop = False
        self.enable = self.config.get("cache")
        self.aria2c_parameters = self.config.get("aria2c_parameters")
Esempio n. 7
0
    def post(self):
        Guser = users.get_current_user()
        if Guser:

            vstrCampaignID = self.request.get('vstrCampaignID')

            findRequest = Campaigns.query(
                Campaigns.strCampaignID == vstrCampaignID)
            thisCampaignList = findRequest.fetch()

            if len(thisCampaignList) > 0:
                thisCampaign = thisCampaignList[0]
            else:
                thisCampaign = Campaigns()

            if not (thisCampaign.strPromoted):
                findRequest = Constant.query(
                    Constant.strReference == Guser.user_id())
                thisConstantList = findRequest.fetch()
                if len(thisConstantList) > 0:
                    thisConstant = thisConstantList[0]
                else:
                    thisConstant = Constant()

                thisConstant.writeReference(strinput=Guser.user_id())
                thisConstant.put()

                findRequest = Profile.query(
                    Profile.strReference == Guser.user_id())
                thisProfileList = findRequest.fetch()
                if len(thisProfileList) > 0:
                    thisProfile = thisProfileList[0]
                else:
                    thisProfile = Profile()

                thisProfile.writeReference(strinput=Guser.user_id())

                if (thisProfile.strWallet > thisConstant.strPromotionCost):
                    thisProfile.strWallet = thisProfile.strWallet - thisConstant.strPromotionCost
                    thisCampaign.strPromoted = True
                    thisProfile.put()
                    thisCampaign.put()
                    self.response.write("Campaign Successfully Promoted")
                else:
                    self.response.write(
                        "Campaign cannot be promoted insufficient funds")
            else:
                self.response.write("Campaign Already Promoted")
Esempio n. 8
0
 def __init__(self):
     if hasattr(self, '_init'):
         return
     self._init = True
     self.const = Constant()
     self.config_file_path = self.const.conf_dir + "/config.json"
     self.default_config = {
         "version": 6,
         "cache": {
             "value":
             False,
             "default":
             False,
             "describe":
             "A toggle to enable cache function or not. Set value to true to enable it."
         },
         "mpg123_parameters": {
             "value": [],
             "default": [],
             "describe": "The additional parameters when mpg123 start."
         },
         "aria2c_parameters": {
             "value": [],
             "default": [],
             "describe":
             "The additional parameters when aria2c start to download something."
         },
         "music_quality": {
             "value":
             0,
             "default":
             0,
             "describe":
             "Select the quality of the music. May be useful at the terrible network connection. "
             "0 for high quality, 1 for medium and 2 for low."
         },
         "global_play_pause": {
             "value":
             "<ctrl><alt>p",
             "default":
             "<ctrl><alt>p",
             "describe":
             "Global keybind for play/pause."
             "Uses gtk notation for keybinds."
         },
         "global_next": {
             "value":
             "<ctrl><alt>j",
             "default":
             "<ctrl><alt>j",
             "describe":
             "Global keybind for next song."
             "Uses gtk notation for keybinds."
         },
         "global_previous": {
             "value":
             "<ctrl><alt>k",
             "default":
             "<ctrl><alt>k",
             "describe":
             "Global keybind for previous song."
             "Uses gtk notation for keybinds."
         },
         "notifier": {
             "value": True,
             "default": True,
             "describe": "Notifier when switching songs."
         },
         "translation": {
             "value": True,
             "default": True,
             "describe": "Foreign language lyrics translation."
         },
         "osdlyrics": {
             "value": False,
             "default": False,
             "describe": "Desktop lyrics for musicbox."
         },
         "osdlyrics_transparent": {
             "value": False,
             "default": False,
             "describe": "Desktop lyrics transparent bg."
         },
         "osdlyrics_color": {
             "value": [225, 248, 113],
             "default": [225, 248, 113],
             "describe": "Desktop lyrics RGB Color."
         },
         "osdlyrics_font": {
             "value": ['Decorative', 16],
             "default": ['Decorative', 16],
             "describe": "Desktop lyrics font-family and font-size."
         },
         "osdlyrics_background": {
             "value": "rgba(100, 100, 100, 120)",
             "default": "rgba(100, 100, 100, 120)",
             "describe": "Desktop lyrics background color."
         },
         "osdlyrics_on_top": {
             "value": True,
             "default": True,
             "describe": "Desktop lyrics OnTopHint."
         },
         "osdlyrics_window_border": {
             "value": True,
             "default": True,
             "describe": "Desktop lyrics show window border."
         },
     }
     self.config = {}
     if not os.path.isfile(self.config_file_path):
         self.generate_config_file()
     try:
         f = file(self.config_file_path, "r")
     except:
         log.debug("Read config file error.")
         return
     try:
         self.config = json.loads(f.read())
     except:
         log.debug("Load config json data failed.")
         return
     f.close()
     if not self.check_version():
         self.save_config_file()
Esempio n. 9
0
 def __init__(self):
     if hasattr(self, '_init'):
         return
     self._init = True
     self.const = Constant()
     self.config_file_path = self.const.conf_dir + "/config.json"
     self.default_config = {
         "version": 4,
         "cache": {
             "value":
             False,
             "default":
             False,
             "describe":
             "A toggle to enable cache function or not. Set value to true to enable it."
         },
         "mpg123_parameters": {
             "value": [],
             "default": [],
             "describe": "The additional parameters when mpg123 start."
         },
         "aria2c_parameters": {
             "value": [],
             "default": [],
             "describe":
             "The additional parameters when aria2c start to download something."
         },
         "music_quality": {
             "value":
             0,
             "default":
             0,
             "describe":
             "Select the quality of the music. May be useful at the terrible network connection. "
             "0 for high quality, 1 for medium and 2 for low."
         },
         "global_play_pause": {
             "value":
             "<ctrl><alt>p",
             "default":
             "<ctrl><alt>p",
             "describe":
             "Global keybind for play/pause."
             "Uses gtk notation for keybinds."
         },
         "global_next": {
             "value":
             "<ctrl><alt>j",
             "default":
             "<ctrl><alt>j",
             "describe":
             "Global keybind for next song."
             "Uses gtk notation for keybinds."
         },
         "global_previous": {
             "value":
             "<ctrl><alt>k",
             "default":
             "<ctrl><alt>k",
             "describe":
             "Global keybind for previous song."
             "Uses gtk notation for keybinds."
         },
         "notifier": {
             "value": True,
             "default": True,
             "describe": "Notifier when switching songs."
         },
         "translation": {
             "value": True,
             "default": True,
             "describe": "Foreign language lyrics translation."
         }
     }
     self.config = {}
     if not os.path.isfile(self.config_file_path):
         self.generate_config_file()
     try:
         f = file(self.config_file_path, "r")
     except:
         log.debug("Read config file error.")
         return
     try:
         self.config = json.loads(f.read())
     except:
         log.debug("Load config json data failed.")
         return
     f.close()
     if not self.check_version():
         self.save_config_file()
Esempio n. 10
0
 def __init__(self):
     self.logMessage = LogMessage()
     self.const = Constant()
     self.processSensorData = ProcessSensorReading()
     if self.const.live:
         self.lcd = RPILCD()
Esempio n. 11
0
 def __init__(self):
     if hasattr(self, '_init'):
         return
     self._init = True
     self.const = Constant()
     self.config_file_path = self.const.conf_dir + '/config.json'
     self.default_config = {
         'version': 6,
         'cache': {
             'value': False,
             'default': False,
             'describe':
             ('A toggle to enable cache function or not. '
              'Set value to true to enable it.')
         },
         'mpg123_parameters': {
             'value': [],
             'default': [],
             'describe': 'The additional parameters when mpg123 start.'
         },
         'aria2c_parameters': {
             'value': [],
             'default': [],
             'describe':
             ('The additional parameters when '
              'aria2c start to download something.')
         },
         'music_quality': {
             'value': 0,
             'default': 0,
             'describe':
             ('Select the quality of the music. '
              'May be useful at the terrible network connection. '
              '0 for high quality, 1 for medium and 2 for low.')
         },
         'global_play_pause': {
             'value': '<ctrl><alt>p',
             'default': '<ctrl><alt>p',
             'describe': 'Global keybind for play/pause.'
                         'Uses gtk notation for keybinds.'
         },
         'global_next': {
             'value': '<ctrl><alt>j',
             'default': '<ctrl><alt>j',
             'describe': 'Global keybind for next song.'
                         'Uses gtk notation for keybinds.'
         },
         'global_previous': {
             'value': '<ctrl><alt>k',
             'default': '<ctrl><alt>k',
             'describe': 'Global keybind for previous song.'
                         'Uses gtk notation for keybinds.'
         },
         'notifier': {
             'value': True,
             'default': True,
             'describe': 'Notifier when switching songs.'
         },
         'translation': {
             'value': True,
             'default': True,
             'describe': 'Foreign language lyrics translation.'
         },
         'osdlyrics': {
             'value': False,
             'default': False,
             'describe': 'Desktop lyrics for musicbox.'
         },
         'osdlyrics_transparent': {
             'value': False,
             'default': False,
             'describe': 'Desktop lyrics transparent bg.'
         },
         'osdlyrics_color': {
             'value': [225, 248, 113],
             'default': [225, 248, 113],
             'describe': 'Desktop lyrics RGB Color.'
         },
         'osdlyrics_font': {
             'value': ['Decorative', 16],
             'default': ['Decorative', 16],
             'describe': 'Desktop lyrics font-family and font-size.'
         },
         'osdlyrics_background': {
             'value': 'rgba(100, 100, 100, 120)',
             'default': 'rgba(100, 100, 100, 120)',
             'describe': 'Desktop lyrics background color.'
         },
         'osdlyrics_on_top': {
             'value': True,
             'default': True,
             'describe': 'Desktop lyrics OnTopHint.'
         },
     }
     self.config = {}
     if not os.path.isfile(self.config_file_path):
         self.generate_config_file()
     try:
         f = file(self.config_file_path, 'r')
     except IOError:
         log.debug('Read config file error.')
         return
     try:
         self.config = json.loads(f.read())
     except ValueError:
         log.debug('Load config json data failed.')
         return
     f.close()
     if not self.check_version():
         self.save_config_file()
Esempio n. 12
0
    def post(self):
        Guser = users.get_current_user()
        if Guser:
            vstrCampaignType = self.request.get('vstrCampaignType')
            vstrCampaignName = self.request.get('vstrCampaignName')
            vstrCampaignIntro = self.request.get('vstrCampaignIntro')
            vstrCampaignBody = self.request.get('vstrCampaignBody')
            vstrFundMe = self.request.get('vstrFundMe')

            findRequest = Constant.query(
                Constant.strReference == Guser.user_id())
            thisConstantList = findRequest.fetch()

            if len(thisConstantList) > 0:
                thisConstant = thisConstantList[0]
            else:
                thisConstant = Constant()

            findRequest = Campaigns.query(
                Campaigns.strReference == Guser.user_id())
            thisCampaignsList = findRequest.fetch()

            findRequest = Profile.query(
                Profile.strReference == Guser.user_id())
            thisProfileList = findRequest.fetch()

            if len(thisProfileList) > 0:
                thisProfile = thisProfileList[0]
            else:
                thisProfile = Profile()

            if (thisProfile.strWallet > thisConstant.strCampaignCost) or (
                    len(thisCampaignsList) <
                    thisConstant.strFreeCampaignAllowance):
                if len(thisCampaignsList
                       ) > thisConstant.strFreeCampaignAllowance:
                    thisProfile.strWallet = thisProfile.strWallet - thisConstant.strCampaignCost
                else:
                    pass
                try:
                    thisCampaign = Campaigns()
                    thisCampaign.writeReference(strinput=Guser.user_id())
                    thisCampaignID = str(Guser.user_id()) + str(
                        len(thisCampaignsList))

                    thisCampaign.writeCampaignID(strinput=thisCampaignID)
                    thisPublicURL = "/campaigns/public/" + thisCampaignID
                    thisPublicURL = thisConstant.strAppURL + thisPublicURL
                    thisCampaign.writeCampaignURL(strinput=thisPublicURL)
                    thisCampaign.writeCampaignName(strinput=vstrCampaignName)
                    if vstrCampaignType == "Personal":
                        thisCampaign.setBusinessCampaign(strinput=True)
                    else:
                        thisCampaign.setBusinessCampaign(strinput=False)

                    thisCampaign.writeCampaignIntro(strinput=vstrCampaignIntro)
                    thisCampaign.writeCampaignBody(strinput=vstrCampaignBody)
                    thisCampaign.writeFundMe(strinput=vstrFundMe)
                    # thisCampaign.setActive() Cannot set the campaign to active since this is a draft
                    StartDate = datetime.datetime.now()
                    StartDate = StartDate.date()
                    EndDate = datetime.date.today() + datetime.timedelta(+30)
                    thisCampaign.setStartDate(strinput=StartDate)
                    thisCampaign.setEndDate(strinput=EndDate)
                    thisInternalURL = "/campaigns/detail/" + thisCampaignID
                    thisCampaign.writeInternalURL(strinput=thisInternalURL)

                    thisCampaign.put()
                    self.response.write("Successfully created your Campaign")
                except:
                    self.response.write("Error Creating Campaign")
            else:
                self.response.write(
                    "Insufficient credit to create a new campaign")