File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change
1
+ import io
1
2
import os
2
3
from pathlib import Path
3
4
4
5
import firebase_admin
5
6
from celery import Celery
6
7
from django .conf import settings
8
+ from django .core .files import File
7
9
from firebase_admin import credentials , messaging
8
10
9
11
from go_capture .sgf .process_image import process_image
@@ -34,17 +36,17 @@ def debug_task(self):
34
36
@app .task
35
37
def process_image_task (image_filename , fcm_token ):
36
38
print (f'token: { fcm_token } ' )
37
- sgf_filename = f'{ Path (image_filename ).stem } .sgf'
38
- sgf_path = settings .SGF_DIR / sgf_filename
39
39
print (f'Processing { image_filename } ' )
40
40
with open (image_filename , 'rb' ) as image_file :
41
- with open ( sgf_path , 'w' ) as sgf_file :
42
- process_image (image_file , sgf_file )
41
+ sgf_buffer = io . StringIO ()
42
+ process_image (image_file , sgf_buffer )
43
43
44
- # See documentation on defining a message payload.
44
+ sgf_buffer .seek (0 )
45
+ sgf_data = sgf_buffer .read ()
46
+ print (sgf_data )
45
47
message = messaging .Message (
46
48
data = {
47
- 'sgf_file ' : str ( sgf_path ) ,
49
+ 'sgf ' : sgf_data ,
48
50
},
49
51
token = fcm_token ,
50
52
)
You can’t perform that action at this time.
0 commit comments