Skip to content

Commit 7a2dc42

Browse files
committed
rename unicode
1 parent 4b90a6c commit 7a2dc42

File tree

3 files changed

+75
-3
lines changed

3 files changed

+75
-3
lines changed

6. Файлы/excel_from_server_only_ipython_2.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@
1313
clr.AddReference('System.Web.Extensions')
1414
from System.Web.Script.Serialization import JavaScriptSerializer
1515

16-
1716
from System import Type, Activator
1817
Excel = Activator.CreateInstance(Type.GetTypeFromProgID("Excel.Application"))
1918

20-
2119
#-----------------------ФУНКЦИИ----------------------
22-
2320
def rsnrequest(p_f_n):
2421
request = WebRequest.Create("http://"+revit_server_name+"/RevitServerAdminRESTService"+version+"/AdminRESTService.svc/|"+p_f_n+"|/contents")
2522
request.Method = "GET"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# -*- coding: utf-8 -*-
2+
import os
3+
import time
4+
from tkinter import Tk, filedialog
5+
6+
root = Tk() # pointing root to Tk() to use it as Tk() in program.
7+
root.withdraw() # Hides small tkinter window.
8+
root.attributes('-topmost', True) # Opened windows will be active. above all windows despite of selection.
9+
open_folder = filedialog.askdirectory()
10+
11+
# tree = os.walk('C:\\test\\Unicode_files')
12+
tree = os.walk(open_folder)
13+
14+
for address, dirs, files in tree:
15+
for file in files:
16+
file_path = address + "\\" + file
17+
clean_file = ""
18+
for symbl in file:
19+
if symbl.isprintable():
20+
clean_file += symbl
21+
print(clean_file)
22+
new_file_path = address + "\\" + clean_file
23+
if os.path.exists(new_file_path):
24+
while os.path.exists(new_file_path):
25+
new_file_path = new_file_path.replace(".", "_.")
26+
time.sleep(1)
27+
print(new_file_path)
28+
os.rename(file_path, new_file_path)

test.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Load the Python Standard and DesignScript Libraries
2+
import sys
3+
sys.path.append(u'C:\\Program Files (x86)\\IronPython 2.7\\Lib')
4+
import json
5+
import clr
6+
import re
7+
8+
import System
9+
from System import DateTime, Text, Environment
10+
from System.Text import Encoding
11+
clr.AddReference('System.Web.Extensions')
12+
from System.Net import WebRequest, ServicePointManager, SecurityProtocolType
13+
14+
clr.AddReference('DynamoRevitDS')
15+
import Dynamo
16+
#access to the current Dynamo instance and workspace
17+
dynamoRevit = Dynamo.Applications.DynamoRevit()
18+
currentWorkspace = dynamoRevit.RevitDynamoModel.CurrentWorkspace
19+
20+
def remove_bad_requestl_symbols(text_to_clear):
21+
return re.sub('[!@#$_]', ' ', text_to_clear)
22+
23+
dyn_file_name = remove_bad_requestl_symbols(currentWorkspace.Name)
24+
25+
def telegram_bot_sendmessage(bot_message):
26+
bot_message = remove_bad_requestl_symbols(bot_message)
27+
bot_token = "5366350020:AAFmLWCOy2FLKVw7ksmmjkt35nHdUUgbk3E"
28+
#bot_chatID = "236079948" #user id
29+
bot_chatID = "-1001782932924" #chat_id
30+
#send_text = telegram_bot_sendmessage("{1}\n{2}".format())
31+
send_text = "https://api.telegram.org/bot{0}/sendMessage?chat_id={1}&parse_mode=Markdown&text={2}\nuser: {3}\ndyn: {4}\n🐈{5}".format(bot_token, bot_chatID, str(DateTime.Now), Environment.UserName, dyn_file_name, bot_message) #dir
32+
#send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + bot_chatID + '&parse_mode=Markdown&text=' + bot_message
33+
#send_text = "https://api.telegram.org/bot5366350020:AAFmLWCOy2FLKVw7ksmmjkt35nHdUUgbk3E/getMe"
34+
#send_text = 'https://api.telegram.org/bot5366350020:AAFmLWCOy2FLKVw7ksmmjkt35nHdUUgbk3E/getUpdates?offset=469437945'
35+
#send_text = "https://api.telegram.org/bot5366350020:AAFmLWCOy2FLKVw7ksmmjkt35nHdUUgbk3E/sendMessage?chat_id=236079948&parse_mode=Markdown&text=test"
36+
#ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
37+
request = WebRequest.Create(send_text)
38+
rsp = request.GetResponse()
39+
#stream_reader = StreamReader(rsp.GetResponseStream())
40+
#jsonData = stream_reader.ReadToEnd()
41+
#json_deserialaized = JavaScriptSerializer().DeserializeObject(jsonData)
42+
#return json_deserialaized
43+
44+
45+
telegram_bot_sendmessage("test_message")
46+
47+
OUT = dyn_file_name

0 commit comments

Comments
 (0)