class TestUploadFile(unittest.TestCase): def setUp(self): self.vika = Vika(TEST_API_TOKEN) self.vika.set_api_base(TEST_API_BASE) self.dst = self.vika.datasheet(TEST_TABLE) def test_upload_file(self): test_url = "https://img9.doubanio.com/view/subject/s/public/s26849345.jpg" test_file = self.dst.upload_file(test_url) self.record = self.dst.records.filter(title="无人生还").get() self.record.cover = [test_file] self.assertIsNotNone(test_file.get("token")) time.sleep(2) test_local_file = "vikaji.png" filepath = os.path.join(os.path.dirname(__file__), test_local_file) test_file = self.dst.upload_file(filepath) self.assertEqual(test_file.get("mimeType"), "image/png") # def test_upload_file_auto(self): # time.sleep(2) # # 显式地传入附件字段,直接为附件字段赋值网络地址,可以自动上传文件。 # self.dst = self.vika.datasheet(TEST_TABLE, attachment_fields=["cover"]) # self.record = self.dst.records.filter(title="无人生还").get() # test_url = "https://img9.doubanio.com/view/subject/s/public/s26849345.jpg" # self.record.cover = [test_url] def tearDown(self): self.record.cover = None
class TestUploadFile(unittest.TestCase): def setUp(self): warnings.simplefilter('ignore', ResourceWarning) self.vika = Vika(TEST_API_TOKEN) self.vika.set_api_base(TEST_API_BASE) self.dst = self.vika.datasheet(TEST_TABLE) def test_upload_file(self): test_url = "https://img9.doubanio.com/view/subject/s/public/s26849345.jpg" test_file = self.dst.upload_attachment(test_url) self.assertIsNotNone(test_file.get("token")) time.sleep(2) test_local_file = "vikaji.png" filepath = os.path.join(os.path.dirname(__file__), test_local_file) test_file = self.dst.upload_file(filepath) self.assertEqual(test_file.get("mimeType"), "image/png")
def setUp(self): vika = Vika(TEST_API_TOKEN) vika.set_api_base(TEST_API_BASE) self.dst = vika.datasheet(TEST_TABLE)
def setUp(self): warnings.simplefilter('ignore', ResourceWarning) vika = Vika(TEST_API_TOKEN) vika.set_api_base(TEST_API_BASE) self.dst = vika.datasheet(TEST_TABLE)
# @Time : 2021/4/26 21:35 # @Author : 桜火 # @Email : [email protected] # @File : aba.py # @Software: PyCharm import json from vika import Vika import os json_file = open("/home/runner/work/_temp/_github_workflow/event.json", mode="r") json_file = json_file.read() vika_token = os.environ["VKTOKEN"] vika_url = os.environ["VKURL"] env = json.loads(json_file) vika = Vika(vika_token) # 通过 datasheetId 来指定要从哪张维格表操作数据。 datasheet = vika.datasheet(vika_url, field_key="id") row = datasheet.records.create({ "fldp3Jyag9dcT": str(env["commits"][0]["id"]), "fldIilczY4AtL": env["repository"]["name"], "fld4CxF56Aiqg": env["repository"]["description"], "fldcNKW9tOQob": env["commits"][0]["author"]["name"], "fldGoBim2N4ru": env["commits"][0]["author"]["username"], "fldoDfcbS2FZT": env["commits"][0]["author"]["email"],
'directorName': get_director_name(html), 'desc': get_desc(html) } def send_msg_to_dingding(msg='none'): webhook = 'https://oapi.dingtalk.com/robot/send?access_token=%s' % os.environ[ 'DINGDING_TOKEN'] secret = os.environ['DINGDING_SECRET'] # 可选:创建机器人勾选“加签”选项时使用 # 初始化机器人小丁 xiaoding = DingtalkChatbot(webhook, secret=secret) xiaoding.send_text(msg=msg, is_at_all=False) if __name__ == '__main__': vika = Vika(os.environ['VIKA_API_TOKEN']) # 影视数据库 dst_imdb = vika.datasheet(os.environ['DATASHEET_ID'], field_key="name") # 分享给外部的 top 250 数据表 dst_sharing = vika.datasheet(os.environ['SHARING_DST_ID'], field_key="id") records = dst_imdb.records.all() url = "https://www.imdb.com/chart/top" imdb_doc = get_html_doc(url) pat = r'<td class="titleColumn">\s*(.*)..*\s*.*\s<a\s.*href="/title/(.*)/.*"\s.*title="(.*)\s.*\(dir\.\).*" >(.*)</a>.*\s*<span class="secondaryInfo">\((.*)\)</span>' movie_tuples = find_all_by_pat(pat, imdb_doc) movie_list = [{