Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
test pattern and add result in a table
#1
Hello,

I need to make a script in order to parse files in a shared folder on windows, making tests of pattern and add results in a table.

In a few words, for each log file, 2 things
if pattern is found -->ok
if pattern is not found --->add error in a table(which will be an html file) with username,email,id of the computer

Here below the script i'm writing

#!/usr/bin/python
# -*- coding: utf-8 -*-
import os.path
import re

data_folder = os.path.join(r"\\shared folder")

file_to_open = os.path.join(data_folder, "*.LOG")

f = open(file_to_open,encoding="utf-8", errors='ignore')

print(f.read())

##controles et actions associes####

## fenetres contextuelles
string = "toto.toto.fr"
regexp = re.findall( r'(^[a-z0-9._-]+@[a-z0-9._-]+\.[(com|fr)]+)')

if re.match(regexp, string) is not None:
print ('TRUE')
else:
print ('FALSE')

etc...

questions

1) how can i write that the script need to parse a shared folder on windows?
2) I've problem with UTF8 and i don't find how to encode it properly?
3) HOW making test pattern and add result in a table (as output)?

Thank you for your help
Larz60+ wrote Mar-05-2019, 01:31 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

Need to also fix indentation (If you add the code tags first, and paste code within, indentation will be preserved)
Quote
#2
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os.path
import re

data_folder = os.path.join(r"\\shared folder\path")

file_to_open = os.path.join(data_folder, "testLOG.txt")

f = open(file_to_open,encoding="utf-8", errors='ignore')

print(f.read())

##controles et actions associes####

## fenetres contextuelles
string = "toto.test.com"
regexp = re.findall( r'(^[a-z0-9._-]+@[a-z0-9._-]+\.[(com|fr)]+)')

if re.match(regexp, string) is not None:
    print ('TRUE')
else:
    print ('FALSE')

print (re.search(regexp, string).groups())

(Mar-05-2019, 02:41 PM)sam1975 Wrote:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os.path
import re

data_folder = os.path.join(r"\\shared folder\path")

file_to_open = os.path.join(data_folder, "testLOG.txt")

f = open(file_to_open,encoding="utf-8", errors='ignore')

print(f.read())

##controles et actions associes####

## fenetres contextuelles
string = "toto.test.com"
regexp = re.findall( r'(^[a-z0-9._-]+@[a-z0-9._-]+\.[(com|fr)]+)')

if re.match(regexp, string) is not None:
    print ('TRUE')
else:
    print ('FALSE')

print (re.search(regexp, string).groups())

questions

1) how can i write that the script need to parse a shared folder on windows?
2) I've problem with UTF8 and i don't find how to encode it properly?
3) HOW making test pattern and add result in a table (as output)?
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Force calculation result as decimal vercetty92 4 79 Mar-20-2019, 02:27 PM
Last Post: vercetty92
  Test Case Assertion Error moga2003 10 273 Mar-18-2019, 01:06 AM
Last Post: moga2003
  Transposing Table salihozturk 3 117 Mar-03-2019, 06:55 PM
Last Post: salihozturk
  new python package test ramkrishna 0 64 Feb-25-2019, 12:18 PM
Last Post: ramkrishna
  My code is taking longer time to give result rajeshwin 4 117 Feb-20-2019, 08:18 PM
Last Post: ichabod801
  python hmac gave different result than php hash_hmac nadavvin 2 92 Feb-18-2019, 03:35 PM
Last Post: nadavvin
  unittest.assertEqual giving failure on result although it's ok. FWendeburg 3 106 Feb-17-2019, 08:58 AM
Last Post: buran
  Unexpected expected type error result MartinMaker 1 120 Feb-16-2019, 05:02 PM
Last Post: micseydel
  How to make loop go back to the beginning if test evaluaes to True. FWendeburg 1 112 Feb-13-2019, 01:26 AM
Last Post: stullis
  How to print from all line in between two pattern kttan 8 216 Feb-08-2019, 03:40 PM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)