def playlist(client): """(list) return a html formatted list containig the actual playlist retrived from mpd""" try: client.connect('localhost', 6600) except Exception: pass try: cs = client.currentsong()['title'][:20] except Exception: cs = "n/a" client.iterate = True playlist_info = [] for song in client.playlistinfo(): pos_val = int(song['pos']) + 1 pos = str(pos_val) if len(song['title']) > 30: title = str(song['title'])[:28] + '..' else: title = song['title'] artist = song['artist'] t = methods.time_convertion(int(song["time"])) time = str(t[2]) + '.' + str(t[3]) tl = time.split(sep='.') if len(tl[-1]) < 2: time = time + '0' out = [pos, title, artist, time] o = methods.create_dict(out) if title[:20] == cs: outstring = methods.insert_data(methods.format_string(format_file2), o) else: outstring = methods.insert_data(methods.format_string(format_file), o) playlist_info.append(outstring) return(playlist_info)
def process_mailbox(mailbox): """(list) return a list with html formatted unread messages from a choosen mailbox. Require as only argument the mailbox initialized and selected using imaplib std module functions""" rv, data = mailbox.search(None, "unseen") if rv != 'OK': print("No messages found!") info = [] for num in data[0].split(): rv, data = mailbox.fetch(num, '(RFC822)') if rv != 'OK': print("ERROR getting message", num) return msg = email.message_from_bytes(data[0][1]) _num = num.decode("ASCII") _from = msg["From"] # ciclo if per To, se andrea.calzavacca work +=1 se paranoid.nemo home +=1 # capire se è il caso di metterlo qui o in mail.py, più probabile sia meglio # la seconda opzione. Nel caso capire come avere un To affidabile _to = msg["Delivered-To"] try: if len(msg["Subject"]) > 40: _sub = msg["Subject"][:37] + '...' else: _sub = msg["Subject"] except Exception: _sub = '' _date = msg["Date"] _out = [_from, _num, _sub, _date, _to] o = methods.create_dict(_out) outstring = methods.insert_data(methods.format_string(format_file), o) info.append(outstring) return(info)
rc.get_rc(rc_file) css = os.path.join(beshell.Theme.path(), 'style.css.d', rc.CSS) cloud_info = [] if rc.RCLONE == '1': parser = configparser.ConfigParser() rclone_cfg = rc.RCLONE_CONFIG_FILE read_cfg = parser.read(rclone_cfg) services_list = [] for item in parser.sections(): service = parser.get(item, 'type') l = clouds.Rclone.space_info(item, service) d = methods.create_dict(l) outstring = methods.insert_data(methods.format_string(format_file), d) cloud_info.append(outstring) if rc.MEGA == '1': l = clouds.Mega.space_info(rc.SIZE) d = methods.create_dict(l) outstring = methods.insert_data(methods.format_string(format_file), d) cloud_info.append(outstring) info = methods.create_dict(cloud_info) info['{x}'] = css
mi = system_info.machine() # cpu info cpu = system_info.cpu() # ram info ram = system_info.ram() # update info update = system_info.update(pm) # fs info for item in rc.MNT.split(','): l = system_info.fs(item) o = methods.create_dict(l) out = methods.insert_data(methods.format_string(fs_format_file), o) si.append(out) #--------------------------------popolate dict---------------------------------- si_dict = methods.create_dict(si) si_dict["{distro}"] = ds si_dict["{de}"] = de si_dict["{wm}"] = wm si_dict["{ut_days}"] = str(ut[0]) si_dict["{ut_hours}"] = str(ut[1]) si_dict["{ut_minutes}"] = str(ut[2]) si_dict["{ut_seconds}"] = str(ut[3]) si_dict["{hostname}"] = mi[1] si_dict["{kernel_build}"] = mi[2]
rc.get_rc(rc_file) css = os.path.join(theme.path, 'style.css.d', rc.CSS) c = musicpd.MPDClient() info_pl = {} play = os.path.join(theme.path, 'twolame', 'icons', 'play.png') pause = os.path.join(theme.path, 'twolame', 'icons', 'pause.png') stop = os.path.join(theme.path, 'twolame', 'icons', 'stop.png') panel = os.path.join(theme.path, 'twolame', 'icons', 'down.png') info = methods.create_dict(music.process_mpd(c)) info['{x}'] = css if c.status()['state'] == 'play': toggle = pause elif c.status()['state'] == 'pause': toggle = play else: toggle = stop info['{button}'] = toggle info['{dot}'] = panel pl = '' for item in music.playlist(c): pl += item
# the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. import os, sys import alsaaudio from spam import beshell from spam import methods from spam import volume theme = beshell.Theme() css = os.path.join(theme.path, 'style.css.d', 'tl_audio.css') icon = os.path.join(theme.path, "TopPanel", "audio.png") m = alsaaudio.Mixer() vol_info = methods.create_dict(volume.alsa_info(m)) vol_info["{icon}"] = icon vol_info["{x}"] = css