PK!RRsend_sms_freemobile/__init__.pyfrom .application import Application def main(): return Application().run() PK!x@jj"send_sms_freemobile/application.pyimport argparse import logging import sys from .client import FreeClient logger = logging.getLogger(__name__) class Application: def run(self): parser = argparse.ArgumentParser( description="Yet another tool to send SMS through French provider FreeMobile" ) parser.add_argument("message", help="Your message") args = parser.parse_args() if not sys.stdin.isatty(): msg = sys.stdin.read() else: try: msg = args.message.decode(sys.stdin.encoding) except: msg = args.message client = FreeClient() client.load_default_config_file() status, value = client.send_sms(msg) if status != 200: print("SMS not sent: {}".format(value)) sys.exit(1) PK!gsend_sms_freemobile/client.pyimport configparser import logging import os import requests from requests.packages import urllib3 from urllib.parse import quote from xdg import XDG_CONFIG_HOME logger = logging.getLogger(__name__) class FreeClient: BASE_URL = 'https://smsapi.free-mobile.fr/sendmsg' def __init__(self, user=None, password=None): """Create a new Free Mobile SMS API client.""" self._user = user self._password = password self._codes = { 200: "Message send", 400: "Missing parameter", 402: "Too much messages send", 403: "Service not enable", 500: "Server not available", } def load_config_file(self, config_file): """Load a configuration file""" logger.debug("Looking for config file: {}". format(config_file)) if not os.path.isfile(config_file): raise Exception("There is not configuration file at: {}".format(config_file)) with open(config_file) as f: file_content = '[dummy]\n' + f.read() config = configparser.ConfigParser() config.read_string(file_content) cfg = config['dummy'] self._user = cfg.get("user", None) self._password = cfg.get("password", None) def load_default_config_file(self): """Load default configuration file""" config_file = os.path.join(XDG_CONFIG_HOME, "send-sms-freemobile.conf") self.load_config_file(config_file) def send_sms(self, text, **kwargs): """Send a text with current user and password""" if not self._user or not self._password: raise AttributeError("User '{}' or password '{}' is null".format(self._user, self._password)) params = { 'user': self._user, 'pass': self._password, 'msg': text.encode('utf-8') } res = requests.get(FreeClient.BASE_URL, params=params, **kwargs) if not res.status_code in self._codes: return res.status_code, "Error message not found" else: return res.status_code, self._codes[res.status_code] PK!Hs`354send_sms_freemobile-0.1.0.dist-info/entry_points.txtN+I/N.,()*NK--1⁌̜T<..PK!HnHTU)send_sms_freemobile-0.1.0.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!H[,send_sms_freemobile-0.1.0.dist-info/METADATASMO@ﯘ@),@MI! Vl쉽e?Hȿڦk̛7z^pϓ/h0:p8EKQ~:aa Ђ7Fҫx4_Y .-꼂ښ(H1yFaRV.kK%Qm.MO޵_Rt-rԎx_AoM *.d.7R=¢KVώnKm]H T}\4Ba n Q/5hgH័ 707%-즳WGYSZ%\s]0M3ΌoS|mRA{Zf4Xm{}|BtQziQOEt#q1 6NxcW].:Z LV5m'ߦ0KKۃYF^pا|<an44 V\c@ϳ&`y@@8 A@X`7@xX )aۛC,y>*}7yļL_K26*dҘG7Ɛqpc45bsPK!HDghc*send_sms_freemobile-0.1.0.dist-info/RECORDͻv0н߂T<:**" KBb Iy}}xN^hC\#tc'Rw %B%}TuS ,mmLlMFОerdE`/|&Y$QFC,L}ax1%OJTK2MΊBiYc'Fapam3u4y,u+F#Δ4c,mաIry7vtN%tj?`&IidKᾮY|vꍇͮI.YK ԎGze{]x]utE"ILdp3_PK!RRsend_sms_freemobile/__init__.pyPK!x@jj"send_sms_freemobile/application.pyPK!g9send_sms_freemobile/client.pyPK!Hs`354 send_sms_freemobile-0.1.0.dist-info/entry_points.txtPK!HnHTU)y send_sms_freemobile-0.1.0.dist-info/WHEELPK!H[,send_sms_freemobile-0.1.0.dist-info/METADATAPK!HDghc*send_sms_freemobile-0.1.0.dist-info/RECORDPKS