IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Python Discussion :

Anomalie lancement programme python


Sujet :

Python

  1. #1
    Expert confirmé

    Avatar de deusyss
    Homme Profil pro
    Expert Python
    Inscrit en
    Mars 2010
    Messages
    1 659
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Expert Python
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2010
    Messages : 1 659
    Par défaut Anomalie lancement programme python
    Bonjour à tous,

    Je suis en train de développer une petite calculatrice Open Source pour un ami: Pycalcar. Elle permet d'effectuer des calculs dans la monnaie de son choix, et des conversions entre monnaies. Chaque monnaie est paramétrables, de même que les taux entre les monnaies, ainsi que la langue du logiciel. Elle a un but historique, pour des recherches dans d'anciennes monnaies.

    Il y a quatre fichiers: un pour l'IHM, un autre pour les calculs, un autre pour les acces à la BDD, un dernier faisant la liaison entre tous. Cela est complété par une BDD SQLITE.

    Je developpe en PYTHON 2.7,sous Geany, sous Linux Mint, et le logiciel fonctionne très bien, conformément aux attentes. A priori seul du paramétrage d'affichage à terminer. Cependant, je rencontre un petit probleme de lancement du logiciel.

    Sous Geany, aucun soucis. Sous un terminal, en lançant la commande "python pycalcar.py" depuis le dossier, aucun soucis. Par contre, si je créé un raccourci avec cette commande terminal, je voit une fenêtre terminal s'ouvrir puis se fermer immédiatement. De même, en rendant les fichiers exécutable, et en lançant pycalcar.py, même scénario.

    Je dois passer à côté de quelque chose de bête je pense, mais je ne voit pas quoi. Si quelqu'un peut m'aider. Je joint mon projet à ce post pour ceux qui voudrait m'aider, et les curieux
    Fichiers attachés Fichiers attachés

  2. #2
    Expert confirmé

    Avatar de deusyss
    Homme Profil pro
    Expert Python
    Inscrit en
    Mars 2010
    Messages
    1 659
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Expert Python
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2010
    Messages : 1 659
    Par défaut
    Bon apres un peu de recherche complementaire et differentes technique testée, j'ai ciblé un peu plus mon probleme. Cela se passe dans le module sqlite_pycalcar.py.

    A chaque execution de requete j'ai un message d'erreur de la part de sqlite3, qui passe silencieusement sous Geany: (<class 'sqlite3.OperationalError'>, OperationalError('no such table: CONFIG',)

    le nom de la table change en fonction de la requete mais c'est toujours à ce niveau que ça deconne. Pourtant, tout se charge sans anomalie au sein du logiciel.

    Une idée? Le code de sqlite_pycalcar:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    892
    893
    894
    895
    896
    897
    898
    899
    900
    901
    902
    903
    904
    905
    906
    907
    908
    909
    910
    911
    912
    913
    914
    915
    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    927
    928
    929
    930
    931
    932
    933
    934
    935
    936
    937
    938
    939
    940
    941
    942
    943
    944
    945
    946
    947
    948
    949
    950
    951
    952
    953
    954
    955
    956
    957
    958
    959
    960
    961
    962
    963
     
    #!/usr/bin/env python
    # -*-coding:utf-8 -*
     
    #	Pycalcar
    #	Copyright (C) 2013 GALODE A.
    #
    #	This file is part of Pycalcar.
    # 
    #	Pycalcar is free software: you can redistribute it and/or modify
    #	it under the terms of the GNU General Public License as published by
    #	the Free Software Foundation, either version 3 of the License, or
    #	(at your option) any later version.
    # 
    #	Pycalcar 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 Pycalcar.  If not, see <http://www.gnu.org/licenses/>
     
    import sqlite3
    import sys
     
     
    """
            :
            
            G{importgraph Demo}
    """
     
    class SqlitePycalcar:
    	"""
                    :
                    
                    G{classtree}
                    
                    DESCRIPTION
                    ===========
                            Allow to access to the DataBase of PYCALCAR
     
                    FUNCTIONS
                    =========
                            p_ins_money
                            -----------
                                    Creation of a new money
                            p_ins_rate
                            ----------
                                    Creation of a new rate between devise
                            p_upd_money
                            -----------
                                    Update of a money's DATA
                            p_upd_rate
                            ----------
                                    Update of money's rate
                            p_del_money
                            -----------
                                    Delete a Money
                            p_del_rate
                            ----------
                                    Delete all rate attach to a devise which has been delete
                            f_read_money_name
                            -----------------
                                    Allow to read a money's DATA
                            f_read_money_rate
                            -----------------
                                    Allow to read a money's DATA internal rate conversion
                            f_read_lang
                            -----------
                                    Allow to read the different language available for Pycalcar
                            f_config_get_language
                            ---------------------
                                    Allow to know the active language
                            p_config_set_language
                            ---------------------
                                    Allow to set the selected language for Pycalcar
                            f_read_rate
                            -----------
                                    Allow to read money's rate conversion   
                            f_read_conv_combox
                            ------------------
                                    Allow to know the available money for convertion end the rate to apply
                            f_read_message
                            --------------
                                    Allow to get the different messages in the selected language
                            f_read_menu_text
                            ----------------
                                    Allow to extract text of IHM    
                            
                    TABLE
                    =====
                            ABOUT
                            -----
                                    Contains the different information for about windows
                                    Columns: Action, Message
                                    
                            CONFIG
                            ------
                                    Contains the parameters for the software
                                    Columns: Lang, Screen, Action, Message
                            
                            MONEY
                            -----
                                    Contains the data of every money
                                    Columns: Name, Year, Nation, Nb_unit, Unit0, Unit1, Unit2, Unit3, Unit4, Unit5, Unit6,
                                    Unit7, unit8, Unit9, Unit1_to_0, Unit2_to_1, unit3_to_2, unit4_to_3, Unit5_to_4,
                                    Unit6_to_5, unit7_to_6, Unit8_to_7, Unit9_to_8
                            
                            RATE
                            ----
                                    Contains the rate to convert form money1 to money2
                                    Columns: Name1, Year1, Nation1, Name2, Year2, Nation2, Rate1_to_2
     
            """
     
     
    	#===================================================#
    	#                       Init                        #
    	#===================================================#
    	def __init__(self) :
    		#bdd_path = ".//..//01-BDD//PYCALCAR.sqlite"
    		bdd_path = "PYCALCAR.sqlite"
     
    		self.bdd_pycalcar = sqlite3.connect(bdd_path)
    		self.bdd_pycalcar.text_factory = str
    		self.bdd_pycalcar.row_factory = sqlite3.Row
     
     
     
    	#===================================================#
    	#         Creation d'une nouvelle monnaie           #
    	#===================================================#
    	def p_ins_money(self,name,year,nation,nb_unit,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9, \
    				  tx0,tx1,tx2,tx3,tx4,tx5,tx6,tx7,tx8):
    		"""
                            :
                                    
                            DESCRIPTION
                            ===========
                                    Creation of a new money
                            
                            PARAMETERS
                            ==========
                                    name
                                    ----
                                            Money's name
                                    year
                                    ----
                                            Money's year creation
                                    nation
                                    ------
                                            Nation of the money
                                    nb_unit
                                    -------
                                            Number of unit in the money
                                    u0 => u9
                                    --------
                                            Name of the different units of the money
                                    tx0 => tx8
                                    ----------
                                            Rate between the different units of the money
                                    
                            RETURNS
                            =======
                                    None
                    """
    		bdd_cursor = self.bdd_pycalcar.cursor()
    		bdd_cursor.execute("INSERT INTO MONEY \
    							( \
    								NAME, YEAR,\
    								NATION, NB_UNIT, UNIT0,\
    								UNIT1, UNIT2,\
    								UNIT3, UNIT4,\
    								UNIT5, UNIT6,\
    								UNIT7, UNIT8,\
    								UNIT9, UNIT1_TO_0,\
    								UNIT2_TO_1, UNIT3_TO_2,\
    								UNIT4_TO_3, UNIT5_TO_4,\
    								UNIT6_TO_5, UNIT7_TO_6,\
    								UNIT8_TO_7, UNIT9_TO_8 \
    							) \
    							VALUES \
    							( \
    								?,?,\
    								?,?,?,\
    								?,?,\
    								?,?,\
    								?,?,\
    								?,?,\
    								?,?,\
    								?,?,\
    								?,?,\
    								?,?,\
    								?,?\
    							)", \
    							(name,year,nation,nb_unit,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,\
    							 tx0,tx1,tx2,tx3,tx4,tx5,tx6,tx7,tx8))			
    		bdd_cursor.close()
    		self.bdd_pycalcar.commit()
     
     
     
    	#===================================================#
    	#       Creation de nouveaux taux de conversion     #
    	#===================================================#
    	def p_ins_rate(self,name1,year1,nation1,name2,year2,nation2,rate):
    		"""
                            :
                                    
                            DESCRIPTION
                            ===========
                                    Creation of a new rate between devise
                            
                            PARAMETERS
                            ==========
                                    name1
                                    -----
                                            Name of the first money
                                    year1
                                    -----
                                            Year of creation of the first money
                                    nation1
                                    -------
                                            Nation of the first money
                                    name2
                                    -----
                                            Name of the second money
                                    year2
                                    -----
                                            Year of creation of the second money
                                    nation2
                                    -------
                                            Nation of the second money
                                    rate
                                    ----
                                            Rate to convert money 1 into money 2
                                    
                            RETURNS
                            =======
                                    None
                    """
    		bdd_cursor = self.bdd_pycalcar.cursor()
    		bdd_cursor.execute("INSERT INTO RATE \
    							( \
    								NAME1, YEAR1,\
    								NATION1, NAME2,\
    								YEAR2, NATION2,\
    								RATE1_TO_2\
    							) \
    							VALUES \
    							( \
    								?,?,\
    								?,?,\
    								?,?,\
    								?\
    							)", \
    							(name1,year1,nation1,name2,year2,nation2,rate))			
    		bdd_cursor.close()
    		self.bdd_pycalcar.commit()
     
     
     
    	#===================================================#
    	#                MAJ d'une monnaie                  #
    	#===================================================#	
    	def p_upd_money(self,old_name,old_year,old_nation,name,year,nation, \
    						nb_unit,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9, \
    						tx0,tx1,tx2,tx3,tx4,tx5,tx6,tx7,tx8):
    		"""
                            :
                                    
                            DESCRIPTION
                            ===========
                                    Update of a money's DATA
                            
                            PARAMETERS
                            ==========
                                    old_name
                                    --------
                                            Old name of the money
                                    old_year
                                    --------
                                            Old year of creation of the money
                                    old_nation
                                    ----------
                                            Old nation of the money
                                    name
                                    ----
                                            New name for the money
                                    year
                                    ----
                                            New year of creation for the money
                                    nation
                                    ------
                                            New nation for the money
                                    nb_unit
                                    -------
                                            Number of units in the money
                                    u0 => u9
                                    --------
                                            Name of the different units of the money
                                    tx0 => tx8
                                    ----------
                                            Rate between the different units of the money
                                    
                            RETURNS
                            =======
                                    None
                    """
    		bdd_cursor = self.bdd_pycalcar.cursor()
    		bdd_cursor.execute("UPDATE MONEY \
    							SET NAME = ?, YEAR = ?, \
    							    NATION = ?, UNIT0 = ?, \
    							    UNIT1 = ?, UNIT2 = ?, \
    							    UNIT3 = ?, UNIT4 = ?, \
    							    UNIT5 = ?, UNIT6 = ?, \
    							    UNIT7 = ?, UNIT8 = ?, \
    							    UNIT9 = ?, UNIT1_TO_0 = ?, \
    							    UNIT2_TO_1 = ?, UNIT3_TO_2 = ?, \
    							    UNIT4_TO_3 = ?, UNIT5_TO_4 = ?, \
    							    UNIT6_TO_5 = ?, UNIT7_TO_6 = ?, \
    							    UNIT8_TO_7 = ?, UNIT9_TO_8 = ? \
    							WHERE NAME = ? AND \
    								  YEAR = ? AND \
    								  NATION = ?", \
    							(name,year,nation,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,\
    							 tx0,tx1,tx2,tx3,tx4,tx5,tx6,tx7,tx8,old_name,old_year,old_nation))			
    		bdd_cursor.close()
    		self.bdd_pycalcar.commit()
     
    		bdd_cursor = self.bdd_pycalcar.cursor()
    		bdd_cursor.execute("UPDATE RATE \
    							SET NAME1 = ?, YEAR1 = ?, \
    							    NATION1 = ?\
    							WHERE NAME1 = ? AND \
    								  YEAR1 = ? AND \
    								  NATION1 = ?", \
    							(name,year,nation,old_name,old_year,old_nation))			
    		bdd_cursor.close()
    		self.bdd_pycalcar.commit()
     
    		bdd_cursor = self.bdd_pycalcar.cursor()
    		bdd_cursor.execute("UPDATE RATE \
    							SET NAME2 = ?, YEAR2 = ?, \
    							    NATION2 = ?\
    							WHERE NAME2 = ? AND \
    								  YEAR2 = ? AND \
    								  NATION2 = ?", \
    							(name,year,nation,old_name,old_year,old_nation))		
    		bdd_cursor.close()
    		self.bdd_pycalcar.commit()
     
     
     
     
     
    	#===================================================#
    	#      MAJ de taux de conversion entre monnaies     #
    	#===================================================#
    	def p_upd_rate(self, name1, year1, nation1, name2, year2, nation2, rate):
    		"""
                            :
                                    
                            DESCRIPTION
                            ===========
                                    Update of money's rate
                            
                            PARAMETERS
                            ==========
                                    name1
                                    -----
                                            Name of the first money
                                    year1
                                    -----
                                            Year of creation of the first money
                                    nation1
                                    -------
                                            Nation of the first money
                                    name2
                                    -----
                                            Name of the second money
                                    year2
                                    -----
                                            Year of creation of the second money
                                    nation2
                                    -------
                                            Nation of the second money
                                    rate
                                    ----
                                            Rate to convert money 1 into money 2                    
                            RETURNS
                            =======
                                    None
                    """
    		bdd_cursor = self.bdd_pycalcar.cursor()
    		bdd_cursor.execute("UPDATE RATE \
    							SET RATE1_TO_2 = ? \
    							WHERE NAME1 = ? AND \
    								  YEAR1 = ? AND \
    								  NATION1 = ? AND \
    								  NAME2 = ? AND \
    								  YEAR2 = ? AND \
    								  NATION2 = ?", \
    							(rate,name1,year1,nation1,name2,year2,nation2))			
    		bdd_cursor.close()
    		self.bdd_pycalcar.commit()
     
     
     
    	#===================================================#
    	#             Effacement dune monnaie              #
    	#===================================================#	
    	def p_del_money(self, name, year, nation):
    		"""
                            :
                                    
                            DESCRIPTION
                            ===========
                                    Delete a Money
                            
                            PARAMETERS
                            ==========
                                    name
                                    ----
                                            New name for the money
                                    year
                                    ----
                                            New year of creation for the money
                                    nation
                                    ------
                                            New nation for the money                                
                                                    
                            RETURNS
                            =======
                                    None
                    """
    		bdd_cursor = self.bdd_pycalcar.cursor()
    		bdd_cursor.execute("DELETE FROM MONEY \
    							WHERE NAME = ? AND \
    								  YEAR = ? AND \
    								  NATION = ?", \
    								  (name,year,nation))
     
    		bdd_cursor.execute("DELETE FROM RATE \
    							WHERE (NAME1 = ? AND \
    								   YEAR1 = ? AND \
    								   NATION1 = ?)", \
    								  (name,year,nation))
     
    		bdd_cursor.execute("DELETE FROM RATE \
    							WHERE (NAME2 = ? AND \
    								   YEAR2 = ? AND \
    								   NATION2 = ?)", \
    								  (name,year,nation))
     
    		bdd_cursor.close()
    		self.bdd_pycalcar.commit()
     
     
     
     
    	#===================================================#
    	#       Effacement des taux lies a une monnaie      #
    	#===================================================#	
    	def p_del_rate(self,name1,year1,nation1,name2='',year2='',nation2=''):
    		"""
                            :
                                    
                            DESCRIPTION
                            ===========
                                    Delete all rate attach to a devise which has been delete
                            
                            PARAMETERS
                            ==========
                                    name1
                                    -----
                                            Name of the first money
                                    year1
                                    -----
                                            Year of creation of the first money
                                    nation1
                                    -------
                                            Nation of the first money
                                    name2
                                    -----
                                            Name of the second money
                                    year2
                                    -----
                                            Year of creation of the second money
                                    nation2
                                    -------
                                            Nation of the second money
                                    rate
                                    ----
                                            Rate to convert money 1 into money 2                            
                                                    
                            RETURNS
                            =======
                                    None
                    """
    		bdd_cursor = self.bdd_pycalcar.cursor()
    		bdd_cursor.execute("DELETE FROM RATE \
    							WHERE (NAME1 = ? AND \
    								   YEAR1 = ? AND \
    								   NATION1 = ? AND\
    								   NAME2 = ? AND \
    								   YEAR2 = ? AND \
    								   NATION2 = ?)", \
    								  (name1,year1,nation1,name2,year2,nation2))
     
    		bdd_cursor.execute("DELETE FROM RATE \
    							WHERE (NAME1 = ? AND \
    								   YEAR1 = ? AND \
    								   NATION1 = ? AND\
    								   NAME2 = ? AND \
    								   YEAR2 = ? AND \
    								   NATION2 = ?)", \
    								  (name2,year2,nation2,name1,year1,nation1))
     
    		bdd_cursor.close()
    		self.bdd_pycalcar.commit()
     
     
     
    	#===================================================#
    	#      Recuperation des unites d'une monnaie        #
    	#===================================================#	
    	def f_read_money_name(self):
    		"""
                            :
                                    
                            DESCRIPTION
                            ===========
                                    Allow to read a money's DATA
                            
                            PARAMETERS
                            ==========
                                    None                            
                                                    
                            RETURNS
                            =======
                                    A list that contains the moneys's data
                                    --------------------------------------
                                            name, year, nation, number of unit,
                                            unit0, unit1, unit2, unit3, unit4,
                                            unit5, unit6, unit7, unit8, unit9
                                    
                    """
    		bdd_cursor = self.bdd_pycalcar.cursor()
    		bdd_cursor.execute("SELECT 	NAME, \
    									YEAR, \
    									NATION, \
    									NB_UNIT, \
    									ifnull(UNIT0,''),\
    									ifnull(UNIT1,''),\
    									ifnull(UNIT2,''),\
    									ifnull(UNIT3,''),\
    									ifnull(UNIT4,''),\
    									ifnull(UNIT5,''),\
    									ifnull(UNIT6,''),\
    									ifnull(UNIT7,''),\
    									ifnull(UNIT8,''),\
    									ifnull(UNIT9,'')\
    								FROM  MONEY")
    		money_list = []
    		for r in bdd_cursor:
    			money_list.append(r)
     
    		bdd_cursor.close()
     
    		return money_list
     
     
     
     
    	#===================================================#
    	#    Recuperation des taux interne dune monnaie    	#
    	#===================================================#
    	def f_read_money_rate(self, name, year, nation):
    		"""
                            :
                                    
                            DESCRIPTION
                            ===========
                                    Allow to read a money's DATA internal rate conversion
                            
                            PARAMETERS
                            ==========
                                    name
                                    ----
                                            New name for the money
                                    year
                                    ----
                                            New year of creation for the money
                                    nation
                                    ------
                                            New nation for the money                                
                                                    
                            RETURNS
                            =======
                                    A list that contains the rate between unit of a money
                                    -----------------------------------------------------
                                            unit1_to_0,unit2_to_1,unit3_to_2,unit4_to_3,
                                            unit5_to_4,unit6_to_5,unit7_to_6,unit8_to_7,
                                            unit9_to_8
                    """
    		bdd_cursor = self.bdd_pycalcar.cursor()
    		bdd_cursor.execute("SELECT 	ifnull(UNIT1_TO_0,0), \
    									ifnull(UNIT2_TO_1,0), \
    									ifnull(UNIT3_TO_2,0), \
    									ifnull(UNIT4_TO_3,0), \
    									ifnull(UNIT5_TO_4,0), \
    									ifnull(UNIT6_TO_5,0), \
    									ifnull(UNIT7_TO_6,0), \
    									ifnull(UNIT8_TO_7,0), \
    									ifnull(UNIT9_TO_8,0) \
    								FROM  MONEY \
    								WHERE NAME = ? AND \
    								      YEAR = ? AND \
    								      NATION = ?", \
    								      (name,year,nation))
    		rate_list = []
    		for r in bdd_cursor:
    			rate_list.append(r)
     
    		bdd_cursor.close()
     
    		return rate_list
     
     
     
     
    	#===================================================#
    	#    			Read the allow languages   			#
    	#===================================================#
    	def f_read_lang(self):
    		"""
                            :
                                    
                            DESCRIPTION
                            ===========
                                    Allow to read the different language available for Pycalcar
                            
                            PARAMETERS
                            ==========
                                    None                    
                                                    
                            RETURNS
                            =======
                                    A list that contains the different language available                   
                    """
    		bdd_cursor = self.bdd_pycalcar.cursor()
    		bdd_cursor.execute("SELECT 	DISTINCT LANG \
    							FROM  CONFIG")
    		lang_list = []
    		for r in bdd_cursor:
    			lang_list.append(r)
     
    		bdd_cursor.close()
     
    		return lang_list
     
     
     
     
    	#===================================================#
    	#    			Read the selected language   		#
    	#===================================================#
    	def f_config_get_language(self):
    		"""
                            :
                                    
                            DESCRIPTION
                            ===========
                                    Allow to read the selected language for Pycalcar
                            
                            PARAMETERS
                            ==========
                                    None                    
                                                    
                            RETURNS
                            =======
                                    The selected language for software                      
                    """
    		try:
    			bdd_cursor = self.bdd_pycalcar.cursor()
    			bdd_cursor.execute("SELECT 	MESSAGE \
    								FROM  CONFIG \
    								WHERE LANG = 'ALL' AND \
    								SCREEN = 'ALL' AND\
    								ACTION = 'LANGUAGE'")
    			lang = []
    			for r in bdd_cursor:
    				lang.append(r)
     
    			bdd_cursor.close()
     
    			return lang[0][0]
    		except:
    			print "erreur0:", sys.exc_info()
     
     
     
     
    	#===================================================#
    	#    			Set the software language  			#
    	#===================================================#
    	def p_config_set_language(self, language):
    		"""
                            :
                                    
                            DESCRIPTION
                            ===========
                                    Allow to set the selected language for Pycalcar
                            
                            PARAMETERS
                            ==========
                                    language
                                    --------
                                            The selected language by user
                                                    
                            RETURNS
                            =======
                                    None                    
                    """
    		bdd_cursor = self.bdd_pycalcar.cursor()
    		bdd_cursor.execute("UPDATE CONFIG \
    							SET MESSAGE =  ?\
    							WHERE LANG = 'ALL' AND \
    							SCREEN = 'ALL' AND\
    							ACTION = 'LANGUAGE'", (language,))
     
    		bdd_cursor.close()
    		self.bdd_pycalcar.commit()
     
     
     
     
    	#===================================================#
    	# Recuperation des taux de conversion entre monnaie #
    	#===================================================#
    	def f_read_rate(self,name1,year1,nation1,name2,year2,nation2):
    		"""
                            :
                                    
                            DESCRIPTION
                            ===========
                                    Allow to read money's rate conversion
                            
                            PARAMETERS
                            ==========
                                    name1
                                    -----
                                            Name of the first money
                                    year1
                                    -----
                                            Year of creation of the first money
                                    nation1
                                    -------
                                            Nation of the first money
                                    name2
                                    -----
                                            Name of the second money
                                    year2
                                    -----
                                            Year of creation of the second money
                                    nation2
                                    -------
                                            Nation of the second money
                                    rate
                                    ----
                                            Rate to convert money 1 into money 2            
                                                    
                            RETURNS
                            =======
                                    A list that contains the rate for conversion between the selected moneys
                                    
                    """
    		bdd_cursor = self.bdd_pycalcar.cursor()
    		bdd_cursor.execute("SELECT 	rate1_to_2 \
    							FROM  RATE \
    							WHERE NAME1 = ? AND \
    								  YEAR1 = ? AND \
    								  NATION1 = ? AND \
    								  NAME2 = ? AND \
    								  YEAR2 = ? AND \
    								  NATION2 = ?", \
    							(name1,year1,nation1,name2,year2,nation2))
    		rate_list = []
    		for r in bdd_cursor:
    			rate_list.append(r)
     
    		bdd_cursor.close()
     
    		try:
    			return float(rate_list[0][0])
    		except:
    			return 0
     
     
    	#===================================================#
    	# 		Donnees pour alimenter les combobox			#
    	#===================================================#
    	def f_read_conv_combox(self,name,year,nation):
    		"""
                            :
                                    
                            DESCRIPTION
                            ===========
                                    Allow to know the available money for convertion end the rate to apply
                            
                            PARAMETERS
                            ==========
                                    name
                                    ----
                                            The name of source money
                                    year
                                    ----
                                            The year of creation of the source money
                                    nation
                                    ------
                                            The nation of the source money
                                                    
                            RETURNS
                            =======
                                    A list that contains the name, the year, the nation and the rate of available money
                                    
                    """
    		bdd_cursor = self.bdd_pycalcar.cursor()
    		bdd_cursor.execute("SELECT DISTINCT NAME2,YEAR2,NATION2,rate1_to_2 \
    							FROM  RATE \
    							WHERE NAME1 = ? AND \
    							YEAR1 = ? AND \
    							NATION1 = ?", (name,year,nation))
    		combobox_list = []
    		for r in bdd_cursor:
    			combobox_list.append(r)	
     
    		bdd_cursor.close()
     
     
    		return combobox_list
     
     
     
    	#===================================================#
    	# 			Recuperation des messages				#
    	#===================================================#
    	def f_read_message(self, language):
    		"""
                            :
                                    
                            DESCRIPTION
                            ===========
                                    Allow to get the different messages in the selected language
                            
                            PARAMETERS
                            ==========
                                    language
                                    --------
                                            The language selected by user
                                                    
                            RETURNS
                            =======
                                    A list that contains the different messages by tuples
                                    
                    """
    		bdd_cursor = self.bdd_pycalcar.cursor()
    		bdd_cursor.execute("SELECT ACTION, MESSAGE \
    							FROM  CONFIG \
    							WHERE LANG = ? AND \
    							SCREEN = 'ALL' AND \
    							ACTION LIKE 'MESSAGE%'", (language,))
    		message_list = []
    		for r in bdd_cursor:
    			message_list.append(r)	
     
    		bdd_cursor.close()
     
     
    		return message_list
     
     
     
     
    	#===================================================#
    	#				Texte pour l'IHM					#
    	#===================================================#
    	def f_read_menu_text(self, language = "Francais"):
    		"""
                            :
                                    
                            DESCRIPTION
                            ===========
                                    Allow to extract text of IHM
                            
                            PARAMETERS
                            ==========
                                    language
                                    --------
                                            The language selected by user
                                                    
                            RETURNS
                            =======
                                    Different lists that contains the interface's text
                                    
                    """
    		bdd_cursor = self.bdd_pycalcar.cursor()
    		bdd_cursor.execute("SELECT ACTION, MESSAGE \
    								FROM  CONFIG \
    								WHERE LANG = ? AND \
    								Screen = 'Toolbar'", (language,))
    		toolbar_list = []
    		for r in bdd_cursor:
    			toolbar_list.append(r)
     
     
    		bdd_cursor.execute("SELECT ACTION, MESSAGE \
    								FROM  CONFIG \
    								WHERE LANG = ? AND \
    								Screen = 'CALC'", (language,))
    		calc_list = []
    		for r in bdd_cursor:
    			calc_list.append(r)
     
     
    		bdd_cursor.execute("SELECT ACTION, MESSAGE \
    								FROM  CONFIG \
    								WHERE LANG = ? AND Screen = 'CONV'", (language,))
    		conv_list = []
    		for r in bdd_cursor:
    			conv_list.append(r)
     
     
    		bdd_cursor.execute("SELECT ACTION, MESSAGE \
    								FROM  CONFIG \
    								WHERE LANG = ? AND \
    								Screen = 'PARAM'", (language,))
    		param_list = []
    		for r in bdd_cursor:
    			param_list.append(r)	
     
     
    		bdd_cursor.execute("SELECT ACTION, MESSAGE  \
    								FROM  ABOUT")
    		about_list = []
    		for r in bdd_cursor:
    			about_list.append(r)	
     
    		bdd_cursor.close()
     
    		return toolbar_list, calc_list, conv_list, param_list, about_list
     
     
     
     
     
    #===================================================#
    #                 Main de la classe                 #
    #===================================================#
    if __name__ == '__main__':
    	None

  3. #3
    Expert confirmé

    Avatar de deusyss
    Homme Profil pro
    Expert Python
    Inscrit en
    Mars 2010
    Messages
    1 659
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Expert Python
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2010
    Messages : 1 659
    Par défaut
    Bon, probleme resolu finalement apres 1 jour de recherche intensive.

    Pour tracer, sqlite est un peu vicieux. Si le chemin passé pour la BDD n'existe pas, il créé une nouvelle base avec le meme nom, mais de fait vide. Les tables interrogées ne peuvent donc y exister. Mon mystere, auquel je n'aurai sans doute jamais la réponse, est de savoir comment il alimentait tout de même correctement mon logiciel.

    Mais bref, pour info donc, mon erreur venait d'un chemin erroné. Je fonctionnait en chemin relatif, mais ./ me renvoyait simplement le chemin de mon home, et non de celui ou se trouvait mon script. La solution donc:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    import os, sys
    ...
    path = os.path.dirname(sys.argv[0])
    bdd_path = path + "/../01-BDD/PYCALCAR.sqlite"
    ...
    path récupère le chemin ou se trouve le script en cours d'execution (rmq: tous mes scripts sont dans le même dossier). A partir de là, je peut me ballader dans l'arborescence correctement en mode relatif.

    J'espère que cela servira à quelqu'un d'autre un jour

  4. #4
    Expert confirmé

    Avatar de deusyss
    Homme Profil pro
    Expert Python
    Inscrit en
    Mars 2010
    Messages
    1 659
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Expert Python
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2010
    Messages : 1 659
    Par défaut
    Petit ajout: Concernant le fichier qui refusait de se lancer après que je lui ai indiqué d'etre considéré comme exécutable il s'agit d'un petit truc tout con, mais bien penible

    EN fait, j'ai travaillé sous linux et windows. En travaillant sous windows, les caractère de fins de ligne sont passé de <LF> à <CR><LF>. De fait, lorsque le programme se lançait le script ne charchait pas le shebang, mais le shebang+<CR>, ce qui n'existe pas, d'ou erreur.

    A noter !!!

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. lancement d'un programme Python
    Par Nono Sto dans le forum Général Python
    Réponses: 22
    Dernier message: 26/10/2009, 14h30
  2. Réponses: 145
    Dernier message: 15/02/2009, 11h51
  3. [Lien]erreur dans mon programme python
    Par durnambule dans le forum Général Python
    Réponses: 11
    Dernier message: 29/01/2004, 14h59

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo