Ignore:
Timestamp:
07/13/06 14:39:25 (18 years ago)
Author:
bas
Message:

EmailtoTracScript?:

delete_spam.py.in:

  • Fixed several erros
File:
1 edited

Legend:

Unmodified
Added
Removed
  • emailtotracscript/trunk/delete_spam.py.in

    r69 r99  
    7979                        env = Environment(project, create=0)
    8080                        db = env.get_db_cnx()
    81                        
     81
     82                        attachment_dir = os.path.join(env.path, 'attachments', 'ticket')
     83
    8284                        cursor = db.cursor()
    8385
     
    9092                                        break
    9193                                spam_id =  row[0]
    92                                 attachment_dir = os.path.join(env.get_attachments_dir(), 'ticket', str(spam_id))
    93                                 if os.path.exists(attachment_dir):
     94
     95                                sql_cmd = "DELETE FROM attachment WHERE type='ticket' and id='%s';" %spam_id
     96                                cursor.execute(sql_cmd)
     97
     98                                dir = os.path.join(attachment_dir, str(spam_id))
     99                                if os.path.exists(dir):
    94100                                        if debug:
    95                                                 print 'delete %s : %s' %(spam_id, attachment_dir)
     101                                                print 'delete %s : %s' %(spam_id, dir)
    96102                                        try:
    97                                                 shutil.rmtree(attachment_dir)
     103                                                shutil.rmtree(dir)
    98104                                        except OSError, detail:
    99105                                                print 'Contact system-administrator: %s' %detail
Note: See TracChangeset for help on using the changeset viewer.