Falldog / pyconcrete

Protect your python script, encrypt it as .pye and decrypt when import it
Apache License 2.0
692 stars 149 forks source link

Global variable issue #61

Closed MyraBaba closed 5 years ago

MyraBaba commented 5 years ago

I have definition in the beginning of my python code :


RESET = "\033[0;0m"
RED   = "\033[1;31m"
BLUE  = "\033[1;34m"
CYAN  = "\033[1;36m"
GREEN = "\033[0;32m"
BOLD    = "\033[;1m"
REVERSE = "\033[;7m"

and in my of my function :


def on_connect(client, userdata, flags, rc):
    print(RED ,"** Kozmos bizimle ** Connected flags" + str(flags) + "result code " \
                 + str(rc) + "client1_id " , RESET)

I compiled with

pyconcrete-admin.py compile --source=_mqt_p.py --pye

and when I run ti gives :

log: Caught exception in on_connect: name 'RED' is not defined

any idea ?

Falldog commented 5 years ago

Please post more information, how do you compile / execute the scripts, and the entry point file is .py or .pye?

MyraBaba commented 5 years ago

I compiled :

pyconcrete-admin.py compile --source=_mqt_p.py --pye

and run :

pyconcrete mqt_.pye

MyraBaba commented 5 years ago

@Falldog any idea *

Falldog commented 5 years ago

Not really, can you provide the whole file to me for testing?

MyraBaba commented 5 years ago

Hi, I am creating worker as below :

`num_fetch_threads = 1
model_worker_number = 1
update_db_worker_number = 1
enroll_worker_number = 1
online_enrollment_worker_number = 1

###QUEUEU s
###QUEUEU s

result_queue            = queue.Queue()      ##PUBLISHER WORKER
model_worker_queue      = queue.Queue()      ##Model worker thread
enrolment_queue         = queue.Queue()      ##ENROLMENT queue
online_enrollment_queue = queue.Queue()      ## ONLINE ENROLMENT
result_enrollment_queue = queue.Queue()
indexed_insert_db_queue = queue.Queue()      ## Sisteme eklenen personel'i indexed olarak güncelle

for i in range(update_db_worker_number):
    update_db_worker = Thread(target=update_data_sql_deamon , args=( indexed_insert_db_queue,))
    update_db_worker.setDaemon(True)
    update_db_worker.start()

for i in range(model_worker_number):
    model_worker = Thread(target=model_worker_deamon , args=(i , model_worker_queue,))
    model_worker.setDaemon(True)
    model_worker.start()

for i in range(enroll_worker_number):
    enrolment_worker = Thread(target=enrolment_deamon , args=(enrolment_queue,))
    enrolment_worker.setDaemon(True)
    enrolment_worker.start()

for i in range(online_enrollment_worker_number):
    online_enroll_worker = Thread(target=online_enrollment_deamon , args=(online_enrollment_queue,))
    online_enroll_worker.setDaemon(True)
    online_enroll_worker.start()

###SEND ENROLLMENT RESULT
for i in range(enroll_worker_number):
    send_enrollment_worker = Thread(target=send_enrollment_result_deamon , args=(result_enrollment_queue,))
    send_enrollment_worker.setDaemon(True)
    send_enrollment_worker.start()
`

In this threads when i used pyconcrete def funtions not aware of the global imports and the variables.

I already imported sqlite cv2 and numpy at the top but in threads def it says cant found.

Falldog commented 5 years ago

It's threading issue, duplicate issue with #60

Falldog commented 5 years ago

Please try the latest code, it should be fixed

MyraBaba commented 5 years ago

compiling from the lates code from here right?

I will and let you know thx

MyraBaba commented 5 years ago

The latest code is working without any problem.

thx