master
cherif 2024-11-10 20:50:53 +01:00
parent 31753bd6f5
commit 7be1ddaef1
5 changed files with 1880 additions and 12 deletions

View File

@ -1,9 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="qsdsqqs">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="29/10/2024 - 18h30">
<change afterPath="$PROJECT_DIR$/tools_cherif/freemobile_send_sms.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/tools_cherif/freemobileconfig" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -32,12 +35,13 @@
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;last_opened_file_path&quot;: &quot;C:/Users/billa/Documents/myclass.com/Siteweb/Production/Ela_back/Back_Office&quot;,
&quot;last_opened_file_path&quot;: &quot;C:/Users/billa/Documents/myclass.com/Siteweb/Production/Ela_back/Back_Office/tools_cherif&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.lookFeel&quot;
}
}</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\billa\Documents\myclass.com\Siteweb\Production\Ela_back\Back_Office\tools_cherif" />
<recent name="C:\Users\billa\Documents\myclass.com\Siteweb\Production\Ela_back\Back_Office" />
</key>
</component>
@ -73,13 +77,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00363" summary="31/07/2024 - 17h30">
<created>1722440625816</created>
<option name="number" value="00363" />
<option name="presentableId" value="LOCAL-00363" />
<option name="project" value="LOCAL" />
<updated>1722440625832</updated>
</task>
<task id="LOCAL-00364" summary="02/08/2024 - 17h">
<created>1722612891274</created>
<option name="number" value="00364" />
@ -416,7 +413,14 @@
<option name="project" value="LOCAL" />
<updated>1729684312514</updated>
</task>
<option name="localTasksCounter" value="412" />
<task id="LOCAL-00412" summary="29/10/2024 - 18h30">
<created>1730223616262</created>
<option name="number" value="00412" />
<option name="presentableId" value="LOCAL-00412" />
<option name="project" value="LOCAL" />
<updated>1730223616262</updated>
</task>
<option name="localTasksCounter" value="413" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -458,7 +462,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="01/09/2024 - 14:00" />
<MESSAGE value="01/09/2024 - 20:00" />
<MESSAGE value="03/09/2024 - 20:00" />
<MESSAGE value="04/09/2024 - 23h" />
@ -483,6 +486,7 @@
<MESSAGE value="13/10/2024 - sdfqsdqs14h" />
<MESSAGE value="qsdsq" />
<MESSAGE value="qsdsqqs" />
<option name="LAST_COMMIT_MESSAGE" value="qsdsqqs" />
<MESSAGE value="29/10/2024 - 18h30" />
<option name="LAST_COMMIT_MESSAGE" value="29/10/2024 - 18h30" />
</component>
</project>

File diff suppressed because it is too large Load Diff

13
main.py
View File

@ -97,6 +97,8 @@ import base_partner_catalog_config as base_partner_catalog_config
import Dashbord_queries.BPF as BPF
import type_cours as type_cours
import tools_cherif.freemobile_send_sms as freemobile_send_sms
app = Flask(__name__)
cors = CORS(app, resources={r"/foo": {"origins": "*"}})
app.config['CORS_HEADERS'] = 'Content-Type'
@ -11222,6 +11224,17 @@ def Add_Update_Email_To_Newsletter():
status, retval = mycommon.Add_Update_Email_To_Newsletter(payload)
return jsonify(status=status, message=retval)
"""
API test envoyer sms
"""
@app.route('/myclass/api/send_freemobile_sms/', methods=['POST','GET'])
@crossdomain(origin='*')
def send_freemobile_sms():
# On recupere le corps (payload) de la requete
#payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### send_freemobile_sms payload zzzz = ")
status, retval = freemobile_send_sms.mysy_send_sms()
return jsonify(status=status, message=retval)

View File

@ -0,0 +1,86 @@
#!/usr/bin/python3
import argparse
import configparser
import getpass
import urllib.parse
import urllib.request
import os
#import pwd
import sys
import inspect
from certifi.__main__ import args
"""
def change_user(user):
try:
newuid = pwd.getpwnam(user).pw_uid
os.setuid(newuid)
#if user is found change environ to later resolve its home
pwdentry = pwd.getpwuid(os.geteuid())
os.environ['HOME'] = pwdentry.pw_dir
os.environ['LOGNAME'] = pwdentry.pw_name
except KeyError as e:
sys.exit(f'User {args.user} not found on the system')
"""
def read_config():
print(" ### debut read_config " )
config = configparser.ConfigParser()
configfile = os.path.expanduser('./freemobileconfig')
print(" ### debut configfile = ", configfile )
if not os.path.isfile(configfile):
sys.exit(f'No config file found in {getpass.getuser()} home')
config.read(configfile)
if not (config.has_option('id', 'user') and config.has_option('id', 'key')):
sys.exit('Invalid config file')
print(" ### config === ", config)
return config['id']['user'], config['id']['key']
def send_sms(msg, user=None):
#if user is not None:
# change_user(user)
print(" #### msg = ", msg)
userid, key = read_config()
f = { 'user' : "15383263", 'pass' : "BaRyr28QyuGUfD", 'msg' : "coucoucoucoucouuou"}
print(" #### ff = ", f)
url = "https://smsapi.free-mobile.fr/sendmsg?"
# on encode le tout et on crée l'url d'envoi
goto = url + urllib.parse.urlencode(f)
# on envoie
urllib.request.urlopen(goto)
"""
Fonction d'envoie du sms avec free
"""
def mysy_send_sms():
try:
f = {'user': "93222911", 'pass': "EIOF1AOecBc4LZ", 'msg': "test ligne 2"}
url = "https://smsapi.free-mobile.fr/sendmsg?"
# on encode le tout et on crée l'url d'envoi
goto = url + urllib.parse.urlencode(f)
# on envoie
urllib.request.urlopen(goto)
return True, "SMS Envoyé"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de recherche un article/avis"
return True, "OK"

View File

@ -0,0 +1,5 @@
[id]
# user : votre identifiant freemobile, du type 15383263
user = 15383263
# key : votre clé didentification générée automatiquement par notre service
key = BaRyr28QyuGUfD