فهرست منبع

다시 버그 수정

잉여개발기 6 ماه پیش
والد
کامیت
ec819f6739
5فایلهای تغییر یافته به همراه239 افزوده شده و 235 حذف شده
  1. 222 218
      emergency_tool.py
  2. 1 1
      route/tool/func.py
  3. 2 2
      route/tool/func_render.py
  4. 12 12
      route/tool/func_render_namumark.py
  5. 2 2
      version.json

+ 222 - 218
emergency_tool.py

@@ -52,223 +52,227 @@ print('25. Recalc exist data_set')
 print('26. Change update branch')
 print('27. Change golang port')
 
-what_i_do = input('Insert selection number (EX : 9) : ')
-if what_i_do == '1':
-    try:
-        go_num = int(input('Count (100) : '))
-    except ValueError:
-        go_num = 100
-
-    curs.execute(db_change('select count(*) from data'))
-    count = curs.fetchall()
-    count = count[0][0] if count else 0
-
-    num = 0
-    title = []
-    print('Load...')
-
-    while num == 0 or len(title) == 100:
-        curs.execute(db_change('select title from data limit ?, 100'), [num])
-        title = curs.fetchall()
-
-        print('Rest : ' + str(count - num))
-        print('Start : ' + title[0][0])
-        time.sleep(1)
-
-        for name in title:
-            num += 1
-            if num % go_num == 0:
-                print(str(num) + ' : ' + name[0])
-
-            curs.execute(db_change("select data from data where title = ?"), [name[0]])
-            data = curs.fetchall()
-
-            render_lang_data = {
-                'toc' : 'toc',
-                'category' : 'category'
-            }
-
-            class_do_render(conn, render_lang_data, '').do_render(name[0], data[0][0], 'backlink')
-elif what_i_do == '2':
-    curs.execute(db_change("delete from other where name = 'recaptcha'"))
-    curs.execute(db_change("delete from other where name = 'sec_re'"))
-elif what_i_do == '3':
-    user_data = input('IP or Name : ')
-
-    curs.execute(
-        db_change(
-            "insert into rb (block, end, today, blocker, why, band, ongoing, login) "
-            "values (?, ?, ?, ?, ?, ?, '', '')"
-        ),
-        [
-            user_data,
-            'release',
-            get_time(),
-            'tool:emergency',
-            '',
-            '',
-        ]
-    )
-
-    curs.execute(db_change("update rb set ongoing = '' where block = ?"), [user_data])
-elif what_i_do == '4':
-    host = input('Host : ')
-
-    curs.execute(db_change("update other set data = ? where name = 'host'"), [host])
-elif what_i_do == '5':
-    port = int(input('Port : '))
-
-    curs.execute(db_change("update other set data = ? where name = 'port'"), [port])
-elif what_i_do == '6':
-    skin = input('Skin name : ')
-
-    curs.execute(db_change("update other set data = ? where name = 'skin'"), [skin])
-elif what_i_do == '7':
-    user_name = input('User name : ')
-    user_pw = input('User password : ')
-
-    hashed = pw_encode(conn, user_pw)
-    curs.execute(db_change("update user_set set data = ? where id = ? and name = 'pw'"), [
-        hashed,
-        user_name
-    ])
-elif what_i_do == '8':
-    new_ver = input('Insert version (0000000) : ')
-
-    if new_ver == '':
-        new_ver = '0000000'
-
-    curs.execute(db_change("update other set data = ? where name = 'ver'"), [new_ver])
-elif what_i_do == '9':
-    if os.path.exists(os.path.join('data', 'set.json')):
-        os.remove(os.path.join('data', 'set.json'))
-elif what_i_do == '10':
-    user_name = input('User name : ')
-    new_name = input('New name : ')
-
-    curs.execute(
-        db_change("update user_set set id = ? where id = ?"),
-        [new_name, user_name]
-    )
-elif what_i_do == '11':
-    if os.path.exists(os.path.join('data', 'mysql.json')):
-        os.remove(os.path.join('data', 'mysql.json'))
-elif what_i_do == '14':
-    curs.execute(db_change('delete from other where name = "head"'))
-elif what_i_do == '15':
-    user_name = input('User name : ')
-
-    curs.execute(db_change("update user_set set data = 'owner' where id = ? and name = 'acl'"), [user_name])
-elif what_i_do == '16':
-    user_name = input('User name : ')
-
-    curs.execute(db_change('select data from user_set where name = "2fa" and id = ?'), [user_name])
-    if curs.fetchall():
-        curs.execute(db_change("update user_set set data = '' where name = '2fa' and id = ?"), [user_name])
-elif what_i_do == '17':
-    markup = input('Markup name : ')
-
-    curs.execute(db_change("update other set data = ? where name = 'markup'"), [markup])
-elif what_i_do == '18':
-    wiki_access_password = input('Password : ')
-
-    curs.execute(db_change("update other set data = ? where name = 'wiki_access_password'"), [wiki_access_password])
-elif what_i_do == '19':
-    curs.execute(db_change('select data from other where name = "update"'))
-    up_data = curs.fetchall()
-    up_data = up_data[0][0] if up_data and up_data[0][0] in ['stable', 'beta', 'dev', 'dont_use'] else 'stable'
-
-    if platform.system() == 'Linux' or platform.system() == 'Darwin':
-        ok = []
-        ok += [os.system('git remote rm origin')]
-        ok += [os.system('git remote add origin https://github.com/opennamu/opennamu.git')]
-        ok += [os.system('git fetch --depth=1 origin ' + up_data)]
-        ok += [os.system('git reset --hard origin/' + up_data)]
-        for for_a in ok[1:]:
-            if for_a != 0:
+async def main():
+    what_i_do = input('Insert selection number (EX : 9) : ')
+    if what_i_do == '1':
+        try:
+            go_num = int(input('Count (100) : '))
+        except ValueError:
+            go_num = 100
+
+        curs.execute(db_change('select count(*) from data'))
+        count = curs.fetchall()
+        count = count[0][0] if count else 0
+
+        num = 0
+        title = []
+        print('Load...')
+
+        while num == 0 or len(title) == 100:
+            curs.execute(db_change('select title from data limit ?, 100'), [num])
+            title = curs.fetchall()
+
+            print('Rest : ' + str(count - num))
+            print('Start : ' + title[0][0])
+            time.sleep(1)
+
+            for name in title:
+                num += 1
+                if num % go_num == 0:
+                    print(str(num) + ' : ' + name[0])
+
+                curs.execute(db_change("select data from data where title = ?"), [name[0]])
+                data = curs.fetchall()
+
+                render_lang_data = {
+                    'toc' : 'toc',
+                    'category' : 'category'
+                }
+
+                await class_do_render(conn, render_lang_data, '').do_render(name[0], data[0][0], 'backlink')
+    elif what_i_do == '2':
+        curs.execute(db_change("delete from other where name = 'recaptcha'"))
+        curs.execute(db_change("delete from other where name = 'sec_re'"))
+    elif what_i_do == '3':
+        user_data = input('IP or Name : ')
+
+        curs.execute(
+            db_change(
+                "insert into rb (block, end, today, blocker, why, band, ongoing, login) "
+                "values (?, ?, ?, ?, ?, ?, '', '')"
+            ),
+            [
+                user_data,
+                'release',
+                get_time(),
+                'tool:emergency',
+                '',
+                '',
+            ]
+        )
+
+        curs.execute(db_change("update rb set ongoing = '' where block = ?"), [user_data])
+    elif what_i_do == '4':
+        host = input('Host : ')
+
+        curs.execute(db_change("update other set data = ? where name = 'host'"), [host])
+    elif what_i_do == '5':
+        port = int(input('Port : '))
+
+        curs.execute(db_change("update other set data = ? where name = 'port'"), [port])
+    elif what_i_do == '6':
+        skin = input('Skin name : ')
+
+        curs.execute(db_change("update other set data = ? where name = 'skin'"), [skin])
+    elif what_i_do == '7':
+        user_name = input('User name : ')
+        user_pw = input('User password : ')
+
+        hashed = pw_encode(conn, user_pw)
+        curs.execute(db_change("update user_set set data = ? where id = ? and name = 'pw'"), [
+            hashed,
+            user_name
+        ])
+    elif what_i_do == '8':
+        new_ver = input('Insert version (0000000) : ')
+
+        if new_ver == '':
+            new_ver = '0000000'
+
+        curs.execute(db_change("update other set data = ? where name = 'ver'"), [new_ver])
+    elif what_i_do == '9':
+        if os.path.exists(os.path.join('data', 'set.json')):
+            os.remove(os.path.join('data', 'set.json'))
+    elif what_i_do == '10':
+        user_name = input('User name : ')
+        new_name = input('New name : ')
+
+        curs.execute(
+            db_change("update user_set set id = ? where id = ?"),
+            [new_name, user_name]
+        )
+    elif what_i_do == '11':
+        if os.path.exists(os.path.join('data', 'mysql.json')):
+            os.remove(os.path.join('data', 'mysql.json'))
+    elif what_i_do == '14':
+        curs.execute(db_change('delete from other where name = "head"'))
+    elif what_i_do == '15':
+        user_name = input('User name : ')
+
+        curs.execute(db_change("update user_set set data = 'owner' where id = ? and name = 'acl'"), [user_name])
+    elif what_i_do == '16':
+        user_name = input('User name : ')
+
+        curs.execute(db_change('select data from user_set where name = "2fa" and id = ?'), [user_name])
+        if curs.fetchall():
+            curs.execute(db_change("update user_set set data = '' where name = '2fa' and id = ?"), [user_name])
+    elif what_i_do == '17':
+        markup = input('Markup name : ')
+
+        curs.execute(db_change("update other set data = ? where name = 'markup'"), [markup])
+    elif what_i_do == '18':
+        wiki_access_password = input('Password : ')
+
+        curs.execute(db_change("update other set data = ? where name = 'wiki_access_password'"), [wiki_access_password])
+    elif what_i_do == '19':
+        curs.execute(db_change('select data from other where name = "update"'))
+        up_data = curs.fetchall()
+        up_data = up_data[0][0] if up_data and up_data[0][0] in ['stable', 'beta', 'dev', 'dont_use'] else 'stable'
+
+        if platform.system() == 'Linux' or platform.system() == 'Darwin':
+            ok = []
+            ok += [os.system('git remote rm origin')]
+            ok += [os.system('git remote add origin https://github.com/opennamu/opennamu.git')]
+            ok += [os.system('git fetch --depth=1 origin ' + up_data)]
+            ok += [os.system('git reset --hard origin/' + up_data)]
+            for for_a in ok[1:]:
+                if for_a != 0:
+                    print('Error : update failed')
+                    
+                    break
+        elif platform.system() == 'Windows':
+            os.system('rd /s /q route')
+            
+            urllib.request.urlretrieve('https://github.com/opennamu/opennamu/archive/' + up_data + '.zip', 'update.zip')
+            
+            zipfile.ZipFile('update.zip').extractall('')
+            
+            ok = os.system('xcopy /y /s /r opennamu-' + up_data + ' .')
+            if ok == 0:
+                os.system('rd /s /q opennamu-' + up_data)
+                os.system('del update.zip')
+            else:
                 print('Error : update failed')
-                
-                break
-    elif platform.system() == 'Windows':
-        os.system('rd /s /q route')
+    elif what_i_do == '20':
+        domain = input('Domain (EX : 2du.pythonanywhere.com) : ')
+
+        curs.execute(db_change('delete from other where name = "domain"'))
+        curs.execute(db_change('insert into other (name, data, coverage) values ("domain", ?, "")'), [domain])
+    elif what_i_do == '21':
+        tls_v = input('TLS (http) [http, https] : ')
+        if not tls_v in ['http', 'https']:
+            tls_v = 'http'
+
+        curs.execute(db_change('delete from other where name = "http_select"'))
+        curs.execute(db_change('insert into other (name, data, coverage) values ("http_select", ?, "")'), [tls_v])
+    elif what_i_do == '22':
+        curs.execute(db_change('delete from other where name = "body"'))
+    elif what_i_do == '23':
+        curs.execute(db_change('delete from other where name = "bottom_body"'))
+    elif what_i_do == '24':
+        load_db = get_db_connect('mysql')
+        mysql_conn = load_db.__enter__()
+        mysql_curs = mysql_conn.cursor()
         
-        urllib.request.urlretrieve('https://github.com/opennamu/opennamu/archive/' + up_data + '.zip', 'update.zip')
-        
-        zipfile.ZipFile('update.zip').extractall('')
-        
-        ok = os.system('xcopy /y /s /r opennamu-' + up_data + ' .')
-        if ok == 0:
-            os.system('rd /s /q opennamu-' + up_data)
-            os.system('del update.zip')
-        else:
-            print('Error : update failed')
-elif what_i_do == '20':
-    domain = input('Domain (EX : 2du.pythonanywhere.com) : ')
-
-    curs.execute(db_change('delete from other where name = "domain"'))
-    curs.execute(db_change('insert into other (name, data, coverage) values ("domain", ?, "")'), [domain])
-elif what_i_do == '21':
-    tls_v = input('TLS (http) [http, https] : ')
-    if not tls_v in ['http', 'https']:
-        tls_v = 'http'
-
-    curs.execute(db_change('delete from other where name = "http_select"'))
-    curs.execute(db_change('insert into other (name, data, coverage) values ("http_select", ?, "")'), [tls_v])
-elif what_i_do == '22':
-    curs.execute(db_change('delete from other where name = "body"'))
-elif what_i_do == '23':
-    curs.execute(db_change('delete from other where name = "bottom_body"'))
-elif what_i_do == '24':
-    load_db = get_db_connect('mysql')
-    mysql_conn = load_db.__enter__()
-    mysql_curs = mysql_conn.cursor()
-    
-    load_db = get_db_connect('sqlite')
-    sqlite_conn = load_db.__enter__()
-    sqlite_curs = sqlite_conn.cursor()
-
-    create_data = get_db_table_list()
-    for create_table in create_data:
-        create = ['test'] + create_data[create_table]
-
-        create_r = ', '.join(['%s' for _ in create])
-        create = ', '.join(create)
-        
-        mysql_curs.execute(db_change('delete from ' + create_table))
-        
-        sqlite_curs.execute(db_change('select ' + create + ' from ' + create_table))
-        db_data = sqlite_curs.fetchall()
-        if db_data:
-            mysql_curs.executemany("insert into " + create_table + " (" + create + ") values (" + create_r + ")", db_data)
-elif what_i_do == '25':
-    curs.execute(db_change("select distinct doc_name from data_set where doc_rev = 'not_exist' or doc_rev = ''"))
-    for for_a in curs.fetchall():
-        data_set_exist = ''
-        
-        curs.execute(db_change("select title from data where title = ?"), [for_a[0]])
-        if not curs.fetchall():
-            data_set_exist = 'not_exist'
-
-        curs.execute(db_change("update data_set set doc_rev = ? where doc_name = ? and (doc_rev = '' or doc_rev = 'not_exist')"), [data_set_exist, for_a[0]])
-elif what_i_do == '26':
-    up_data = input('Insert branch name (beta) [stable, beta, dev] : ')
-
-    if not up_data in ['stable', 'beta', 'dev', 'dont_use']:
-        up_data = 'beta'
-
-    curs.execute(db_change('delete from other where name = "update"'))
-    curs.execute(db_change('insert into other (name, data, coverage) values ("update", ?, "")'), [up_data])
-elif what_i_do == '27':
-    port = int(input('Port : '))
-
-    curs.execute(db_change("update other set data = ? where name = 'golang_port'"), [port])
-else:
-    raise ValueError(what_i_do)
-
-if data_db_load == 'Y':
-    try:
-        conn.commit()
-    except:
-        pass
-
-print('OK')
+        load_db = get_db_connect('sqlite')
+        sqlite_conn = load_db.__enter__()
+        sqlite_curs = sqlite_conn.cursor()
+
+        create_data = get_db_table_list()
+        for create_table in create_data:
+            create = ['test'] + create_data[create_table]
+
+            create_r = ', '.join(['%s' for _ in create])
+            create = ', '.join(create)
+            
+            mysql_curs.execute(db_change('delete from ' + create_table))
+            
+            sqlite_curs.execute(db_change('select ' + create + ' from ' + create_table))
+            db_data = sqlite_curs.fetchall()
+            if db_data:
+                mysql_curs.executemany("insert into " + create_table + " (" + create + ") values (" + create_r + ")", db_data)
+    elif what_i_do == '25':
+        curs.execute(db_change("select distinct doc_name from data_set where doc_rev = 'not_exist' or doc_rev = ''"))
+        for for_a in curs.fetchall():
+            data_set_exist = ''
+            
+            curs.execute(db_change("select title from data where title = ?"), [for_a[0]])
+            if not curs.fetchall():
+                data_set_exist = 'not_exist'
+
+            curs.execute(db_change("update data_set set doc_rev = ? where doc_name = ? and (doc_rev = '' or doc_rev = 'not_exist')"), [data_set_exist, for_a[0]])
+    elif what_i_do == '26':
+        up_data = input('Insert branch name (beta) [stable, beta, dev] : ')
+
+        if not up_data in ['stable', 'beta', 'dev', 'dont_use']:
+            up_data = 'beta'
+
+        curs.execute(db_change('delete from other where name = "update"'))
+        curs.execute(db_change('insert into other (name, data, coverage) values ("update", ?, "")'), [up_data])
+    elif what_i_do == '27':
+        port = int(input('Port : '))
+
+        curs.execute(db_change("update other set data = ? where name = 'golang_port'"), [port])
+    else:
+        raise ValueError(what_i_do)
+
+    if data_db_load == 'Y':
+        try:
+            conn.commit()
+        except:
+            pass
+
+    print('OK')
+
+if __name__ == "__main__":
+    asyncio.run(main())

+ 1 - 1
route/tool/func.py

@@ -1424,7 +1424,7 @@ async def render_set(conn, doc_name = '', doc_data = '', data_type = 'view', mar
     if db_data and db_data[0][0] != '':
         render_lang_data['category'] = db_data[0][0]
 
-    get_class_render = class_do_render(
+    get_class_render = await class_do_render(
         conn,
         render_lang_data,
         markup,

+ 2 - 2
route/tool/func_render.py

@@ -25,7 +25,7 @@ class class_do_render:
         random_string = ''.join(random.choice(characters) for _ in range(length))
         return random_string
 
-    def do_render(self, doc_name, doc_data, data_type):
+    async def do_render(self, doc_name, doc_data, data_type):
         curs = self.conn.cursor()
 
         doc_set = {}
@@ -55,7 +55,7 @@ class class_do_render:
             rep_data = db_data[0][0] if db_data else 'namumark'
 
         if rep_data == 'namumark' or rep_data == 'namumark_beta':
-            data_end = class_do_render_namumark(
+            data_end = await class_do_render_namumark(
                 self.conn,
                 doc_name,
                 doc_data,

+ 12 - 12
route/tool/func_render_namumark.py

@@ -268,11 +268,11 @@ class class_do_render_namumark:
 
         return link_main
     
-    def do_inter_render(self, data, doc_include):
+    async def do_inter_render(self, data, doc_include):
         doc_set = dict(self.doc_set)
         doc_set['doc_include'] = doc_include
 
-        data_end = class_do_render_namumark(self.conn, self.doc_name, data, doc_set, self.lang_data, do_type = 'inter')()
+        data_end = await class_do_render_namumark(self.conn, self.doc_name, data, doc_set, self.lang_data, do_type = 'inter')()
 
         self.render_data_js += data_end[1]
         self.data_category_list += data_end[2]['category']
@@ -1358,7 +1358,7 @@ class class_do_render_namumark:
         self.render_data = re.sub(r'(\\+)?@([ㄱ-ㅣ가-힣a-zA-Z0-9_]+)=((?:\\@|[^@\n])+)@', do_render_include_default_sub, self.render_data)
         self.render_data = re.sub(r'(\\+)?@([ㄱ-ㅣ가-힣a-zA-Z0-9_]+)@', do_render_include_default_sub, self.render_data)
 
-    def do_render_include(self):
+    async def do_render_include(self):
         include_num = 0
         include_set_data = get_main_skin_set(self.conn, self.flask_session, 'main_css_include_link', self.ip)
         include_regex = re.compile(r'\[include\(((?:(?!\[include\(|\)\]|<\/div>).)+)\)\](\n?)', re.I)
@@ -1422,7 +1422,7 @@ class class_do_render_namumark:
 
                         include_data = ''
                         if self.parent:
-                            include_data_tmp = self.parent(
+                            include_data_tmp = await self.parent(
                                 self.conn,
                                 doc_name = self.doc_name,
                                 doc_data = db_data[0][0], 
@@ -1865,7 +1865,7 @@ class class_do_render_namumark:
 
             table_count_all -= 1
     
-    def do_render_middle(self):
+    async def do_render_middle(self):
         wiki_count = 0
         html_count = 0
         syntax_count = 0
@@ -2232,18 +2232,18 @@ class class_do_render_namumark:
 
                 return data
 
-            def replace(self, match):
+            async def replace(self, match):
                 data = inter_data[match[1]]
                 data = re.sub(inter_data_regex, self.replace_sub, data)
                 
-                data = self.do_inter_render(data, self.doc_set['doc_include'] + 'opennamu_inter_render_' + str(self.inter_count))
+                data = await self.do_inter_render(data, self.doc_set['doc_include'] + 'opennamu_inter_render_' + str(self.inter_count))
                 data = re.sub(r'\|\|', '<no_td>', data)
                 
                 self.inter_count += 1
 
                 return data
 
-        replace_inter_data_top = do_render_middle_replace_inter_class(self.do_inter_render, self.doc_set)
+        replace_inter_data_top = await do_render_middle_replace_inter_class(self.do_inter_render, self.doc_set)
         self.render_data = re.sub(inter_data_regex, replace_inter_data_top.replace, self.render_data)
         self.render_data = re.sub(r'<temp_(?P<in>(?:slash)_(?:[0-9]+)(?:[^<>]+))>', '<\\g<in>>', self.render_data)
 
@@ -2280,7 +2280,7 @@ class class_do_render_namumark:
                 quote_data = re.sub(r'\n$', '', quote_data)
                 quote_data = self.get_tool_data_revert(quote_data)
 
-                quote_data_end = self.do_inter_render(quote_data, self.doc_set['doc_include'] + 'opennamu_quote_' + str(quote_count))
+                quote_data_end = await self.do_inter_render(quote_data, self.doc_set['doc_include'] + 'opennamu_quote_' + str(quote_count))
                 data_name = self.get_tool_data_storage('<div>', '</div>', quote_data_org)
 
                 self.render_data = re.sub(quote_regex, lambda x : ('\n<front_br><hr class="mini_hr"><blockquote><back_br>\n<' + data_name + '>' + quote_data_end + '</' + data_name + '><front_br></blockquote><hr class="mini_hr"><back_br>\n'), self.render_data, 1)
@@ -2561,7 +2561,7 @@ class class_do_render_namumark:
             opennamu_do_ip_render();\n
         '''
 
-    def __call__(self):
+    async def __call__(self):
         self.do_render_remark()
         self.do_render_include_default()
         self.do_render_slash()
@@ -2570,8 +2570,8 @@ class class_do_render_namumark:
             self.do_render_redirect()
         
         if self.data_redirect == 0:
-            self.do_render_middle()
-            self.do_render_include()
+            await self.do_render_middle()
+            await self.do_render_include()
             self.do_render_math()
             self.do_render_table()
             self.do_render_list()

+ 2 - 2
version.json

@@ -1,6 +1,6 @@
 {
-    "r_ver" : "v3.6.0-Beta-v27",
-    "c_ver" : "20250505",
+    "r_ver" : "v3.6.0-Beta-v28",
+    "c_ver" : "20250506",
     "s_ver" : "20240426",
     "bin_link" : "https://github.com/openNAMU/GopenNAMU/releases/download/v2025-12-07-Beta-v3/"
 }