def buildlist(self): if FacebookHelper.variable_get('access_token', None) is None: self.SetMessage('Please register your box to Facebook App!') api = [] api.append({'name': _("Upload Screen"), 'description': _('Upload current video screenshot with event info'), 'func': self.actions.postimage, 'icon': 'post'}) api.append({'name': _("Friends"), 'description': _('Your Friends'), 'func': self.actions.Friends, 'icon': 'friends'}) api.append({'name': _("Wall"), 'description': _('FB Wall'), 'func': self.actions.Wall, 'icon': 'wall'}) api.append({'name': _("Settings"), 'description': _('Some settings'), 'func': self.actions.Settings, 'icon': 'settings'}) list = [] for x in api: png = LoadPixmap(FacebookHelper.GetIcon(x['icon'])) obj = [ x, MultiContentEntryText(pos=(60, 0), size=(335, 25), font=0, text=x['name']), MultiContentEntryText(pos=(62, 22), size=(335, 17), font=1, text=x['description']), MultiContentEntryPixmapAlphaTest(pos=(5, 0), size=(50, 40), png = png), ] #if x.has_key('needaccess') and self.itemaccess(x['needaccess']) is False: # obj.append(MultiContentEntryPixmapAlphaTest(pos=(395, 5), size=(20, 20), png = access)) list.append(obj) return list
def buildlist(self): #png = boxwrapper.Icon("channellist_list") try: wall = FacebookHelper.FacebookApi().getWall().data() except Exception as e: self.ErrorException(str(e)) return dummy_img = LoadPixmap(FacebookHelper.GetIconPath() + '/dummy.jpg') for x in wall: #name = str(x['name']) msg = x.get('message', '').encode('ascii', 'ignore') name = x.get('name', '').encode('ascii', 'ignore') if str(x.get('type', '')) is 'photo': msg = x.get('story', '').encode('ascii', 'ignore') if str(x.get('type', '')) is 'status': msg = x.get('story', '').encode('ascii', 'ignore') if x.get('from', None): name = x['from'].get('name', '').encode('ascii', 'ignore') if msg is '': msg = x.get('story', '').encode('ascii', 'ignore') img = x.get('picture', None) pixmap = dummy_img if img is not None and img.find("external") == -1: path = FacebookHelper.img_download(str(img)) if path: pixmap = LoadPixmap(path) if img is not None and "external" in img: o = cgi.parse_qs(urlparse(img).query) url = o.get('url')[0].encode("utf-8") if url: path = FacebookHelper.img_download(str(img), FacebookHelper.url_img_ext(url)) if path: pixmap = LoadPixmap(path) print name self.list.append((name, msg, pixmap, x)) #, pixmap, x #list.append([ # msg, # MultiContentEntryText(pos=(60, 0), size=(320, 20), font=0, text=msg), # MultiContentEntryText(pos=(60, 22), size=(320, 17), font=1, text=name), # MultiContentEntryPixmapAlphaTest(pos=(5, 0), size=(50, 40), png = pixmap), # x #]) return self.list
def getTimesFromOneJSON(inputFile, sender='All'): if sender == 'Me': sender = 'Max Whitehouse' times = [] if sender == 'All': for message in fh.getAllMessages(inputFile): times.append(fh.getProperty(message, 'timestamp_ms')) else: for message in fh.getAllMessages(inputFile): if fh.getProperty(message, 'sender_name') == sender: times.append(fh.getProperty(message, 'timestamp_ms')) return times
def buildlist(self): if FacebookHelper.variable_get('access_token', None) is None: self.SetMessage('Please register your box to Facebook App!') api = [] api.append({'name': _("Upload Screen"), 'description': _('Upload current video screenshot with event info'), 'func': self.actions.postimage, 'icon': 'post'}) api.append({'name': _("Friends"), 'description': _('Your Friends'), 'func': self.actions.Friends, 'icon': 'friends'}) api.append({'name': _("Wall"), 'description': _('FB Wall'), 'func': self.actions.Wall, 'icon': 'wall'}) api.append({'name': _("Settings"), 'description': _('Some settings'), 'func': self.actions.Settings, 'icon': 'settings'}) list = [] for x in api: png = LoadPixmap(FacebookHelper.GetIcon(x['icon'])) obj = [ x, MultiContentEntryText(pos=(60, 0), size=(335, 25), font=0, text=x['name']), MultiContentEntryText(pos=(62, 22), size=(335, 17), font=1, text=x['description']), MultiContentEntryPixmapAlphaTest(pos=(5, 0), size=(50, 40), png = png), ] #if x.has_key('needaccess') and self.itemaccess(x['needaccess']) is False: # obj.append(MultiContentEntryPixmapAlphaTest(pos=(395, 5), size=(20, 20), png = access)) list.append(obj) return list
def layoutFinished(self): try: self.path = FacebookHelper.GrabVideoImg() except Exception as e: print "Error:" + str(e) self.ShowPicture(self.path)
def onMenuChanged(self, test1 = ''): obj = self["feedlist"].getCurrent() if obj is False: return obj = obj[-1] img = FacebookHelper.downloadImg(obj['img_large'], self.onLargeProfileImage) if self["profile"].instance is not None: self["profile"].instance.setPixmap(img)
def buildlist(self): try: friends = FacebookHelper.FacebookApi().getFriendsFormated().data() except Exception as e: self.ErrorException(str(e)) return for x in friends: #uname=x['name'].decode("utf-8") name = x['name'].encode('ascii', 'replace') profile_img = LoadPixmap(FacebookHelper.GetIconPath() + '/dummy.jpg') if x.get('img'): img = FacebookHelper.downloadImg(x.get('img'), self.fetchFinished, {'index':len(self.list)}) if img is not None: profile_img = img self.list.append((name, profile_img, x)) self.setFriendsCount() return self.list
def save(self, values): fields = [] if len(values['servicename']) > 0: fields.append(values['servicename']) if len(values['eventname']) > 0: fields.append(values['eventname']) if len(values['comment']) > 0: fields.append(values['comment']) msg = ' - '.join(fields) try: FacebookHelper.FacebookApi().postImage(self.path, msg) except Exception as e: return "Error:" + str(e) return _('Posted to wall')
def buildlist(self): if FacebookHelper.variable_get("access_token", None) is None: self.SetMessage("Please register your box to Facebook App!") api = [] api.append( { "name": _("Upload Screen"), "description": _("Upload current video screenshot with event info"), "func": self.actions.postimage, "icon": "post", } ) api.append( {"name": _("Friends"), "description": _("Your Friends"), "func": self.actions.Friends, "icon": "friends"} ) api.append({"name": _("Wall"), "description": _("FB Wall"), "func": self.actions.Wall, "icon": "wall"}) api.append( { "name": _("Settings"), "description": _("Some settings"), "func": self.actions.Settings, "icon": "settings", } ) list = [] for x in api: png = LoadPixmap(FacebookHelper.GetIcon(x["icon"])) obj = [ x, MultiContentEntryText(pos=(60, 0), size=(335, 25), font=0, text=x["name"]), MultiContentEntryText(pos=(62, 22), size=(335, 17), font=1, text=x["description"]), MultiContentEntryPixmapAlphaTest(pos=(5, 0), size=(50, 40), png=png), ] # if x.has_key('needaccess') and self.itemaccess(x['needaccess']) is False: # obj.append(MultiContentEntryPixmapAlphaTest(pos=(395, 5), size=(20, 20), png = access)) list.append(obj) return list
def main(): csvFile = r"C:\Users\Max\Desktop\Parsed Message Data" \ + r"\Time of messages I have sent.csv" times = fh.RetrieveTimes(csvFile) times = MessWithTimeList(times) n, bins, patches = plt.hist(x=times, bins='auto', color='#0504aa', alpha=0.7, rwidth=0.85) plt.grid(axis='y', alpha=0.75) plt.xlabel('Time') plt.ylabel('Total Messages Sent or Received') plt.title('My Very Own Histogram') Relabel() plt.show()
def GetAndSaveTimes(sender_): '''This function has one arg, sender, this can be 'Me', 'All' or name of a person.''' mainDir = r"C:\Users\Max\Desktop\Parsed Message Data\Cleaned Inbox" newFileName = csvSave() if newFileName == '': return # --- Reading. times = [] for root, dirs, files in fh.walklevelaround(mainDir, 1): if files: for file in files: baseFolder = os.path.basename(root) inputFile = os.path.join(mainDir, baseFolder, file) temp = getTimesFromOneJSON(inputFile, sender=sender_) if temp: times.append(temp) # --- Wrighting. with open(newFileName, 'w+', newline='') as newFile: wr = csv.writer(newFile) for word in times: wr.writerow(word)
def Visualize(self): print('getting statuses...') # get all statuses fbError = False if len(self.User.facebookId) > 0: try: self.User.statuses.extend(fh.getPosts(self.User)) except: fbError = True liTweets = th.getTweets(self.User,maxTweets=self.maxTweets) if len(liTweets) == 0: return [] self.User.statuses.extend(liTweets) # form string to cloud stringToCloud = ' '.join([x.statusText for x in self.User.statuses]) stringToCloud = re.sub('(?<=^|(?<=[^a-zA-Z0-9-_\.]))@([A-Za-z0-9_]+)','',stringToCloud) # prepare custom stop words if self.customStopWords == None: self.customStopWords = list(STOPWORDS) self.customStopWords.append(self.User.twitterId.lower()) for w in self.User.twitterName.split(' '): self.customStopWords.append(w.lower()) self.customStopWords.append(self.User.twitterName.replace(' ','').lower()) langs = [x.language for x in self.User.statuses] for lang in set(langs): if langs.count(lang) > 0.4 * len(self.User.statuses) and lang in global_stopwords: self.customStopWords.extend(global_stopwords[lang]) print('getting profiles...') # get twitter profile for more information self.User = th.fetch_profile(self.User) kbImgPath = "outputImages\\" + self.User.twitterId + "_keyboard.png" keyBoardImage = createKeyBoardHeatMap(stringToCloud) keyBoardImage.save(kbImgPath) # prepare mask if self.customImagePath == None: self.customImage = Image.open(BytesIO(requests.get(self.User.twitterImageURL).content)) else: self.customImage = Image.open(self.customImagePath) print('making pictues...') # make images liImages = Visualizer(self.User,stringToCloud,self.customImage,self.customStopWords,self.bgColor,self.textColor,keyBoardImage,self.includeOtherInfo,self.includeKeyBoard).Visualize() # cleanUp self.customImage.close() if self.User.twitterId.lower() in self.customStopWords: self.customStopWords.remove(self.User.twitterId.lower()) for w in self.User.twitterName.lower().split(' '): if w in self.customStopWords: self.customStopWords.remove(w) if self.User.twitterName.replace(' ','').lower() in self.customStopWords: self.customStopWords.remove(self.User.twitterName.replace(' ','').lower()) return liImages,kbImgPath,fbError
def buildlist(self): #png = boxwrapper.Icon("channellist_list") try: wall = FacebookHelper.FacebookApi().getWall().data() except Exception as e: self.ErrorException(str(e)) return dummy_img = LoadPixmap(FacebookHelper.GetIconPath() + '/dummy.jpg') for x in wall: #name = str(x['name']) msg = x.get('message', '').encode('ascii', 'ignore') name = x.get('name', '').encode('ascii', 'ignore') if str(x.get('type', '')) is 'photo': msg = x.get('story', '').encode('ascii', 'ignore') if str(x.get('type', '')) is 'status': msg = x.get('story', '').encode('ascii', 'ignore') if x.get('from', None): name = x['from'].get('name', '').encode('ascii', 'ignore') if msg is '': msg = x.get('story', '').encode('ascii', 'ignore') img = x.get('picture', None) pixmap = dummy_img if img is not None and img.find("external") == -1: path = FacebookHelper.img_download(str(img)) if path: pixmap = LoadPixmap(path) if img is not None and "external" in img: o = cgi.parse_qs(urlparse(img).query) url = o.get('url')[0].encode("utf-8") if url: path = FacebookHelper.img_download( str(img), FacebookHelper.url_img_ext(url)) if path: pixmap = LoadPixmap(path) print name self.list.append((name, msg, pixmap, x)) #, pixmap, x #list.append([ # msg, # MultiContentEntryText(pos=(60, 0), size=(320, 20), font=0, text=msg), # MultiContentEntryText(pos=(60, 22), size=(320, 17), font=1, text=name), # MultiContentEntryPixmapAlphaTest(pos=(5, 0), size=(50, 40), png = pixmap), # x #]) return self.list
def buildlist(self): list = [] #png = boxwrapper.Icon("channellist_list") try: wall = FacebookHelper.FacebookApi().getWall().data() except Exception as e: self.ErrorException(str(e)) return dummy_img = LoadPixmap(FacebookHelper.GetIconPath() + '/dummy.jpg') for x in wall: #name = str(x['name']) msg = x.get('message', '').encode('ascii', 'ignore') name = x.get('name', '').encode('ascii', 'ignore') if str(x.get('type', '')) is 'photo': msg = x.get('story', '').encode('ascii', 'ignore') if str(x.get('type', '')) is 'status': msg = x.get('story', '').encode('ascii', 'ignore') if x.get('from', None): name = x['from'].get('name', '').encode('ascii', 'ignore') if msg is '': msg = x.get('story', '').encode('ascii', 'ignore') img = x.get('picture', None) pixmap = dummy_img #http://external.ak.fbcdn.net/safe_image.php?d=AQB5kTNOiq63sj4f&w=90&h=90&url=http\u00253A\u00252F\u00252Fbilder.bild.de\u0 if img is not None and img.find("external") == -1: path = FacebookHelper.img_download(str(img)) if path: pixmap = LoadPixmap(path) #if x.get('picture', None): # img = x.get('picture', None) # to = '/tmp/' # client.downloadPage(x.get('picture', None)).addCallback(self.fetchFinished,str(tubeid)).addErrback(self.fetchFailed,str(tubeid)) list.append([ msg, MultiContentEntryText(pos=(60, 0), size=(320, 20), font=0, text=msg), MultiContentEntryText(pos=(60, 22), size=(320, 17), font=1, text=name), MultiContentEntryPixmapAlphaTest(pos=(5, 0), size=(50, 40), png = pixmap), x ]) return list