Skip to content

Commit

Permalink
Some tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinsf committed Jul 19, 2024
1 parent 44ad700 commit e441b79
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
16 changes: 12 additions & 4 deletions rime/filesystem/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# See LICENSE.txt for full details.
# Copyright 2023 Telemarq Ltd
from abc import ABC, abstractmethod
import datetime
import os
import plistlib
import hashlib
Expand Down Expand Up @@ -209,7 +210,7 @@ def create(cls, id_: str, root: str, metadata_db_path: str, template: Optional['
# Create Manifest for file hashing. Do this manually because we don't have a device yet.
syspath = os.path.join(root, 'Manifest.db')

print(f'Creating {syspath}...')
log.info(f'Creating {syspath}...')
with sqlite3_connect_with_regex_support(syspath, read_only=False) as conn:
conn.execute("""CREATE TABLE Files (
fileID TEXT PRIMARY KEY,
Expand All @@ -222,8 +223,15 @@ def create(cls, id_: str, root: str, metadata_db_path: str, template: Optional['

if template is None:
# Create Info.plist.
with open(os.path.join(root, 'Info.plist'), 'wb'):
pass # touch the file to ensure it exists
with open(os.path.join(root, 'Info.plist'), 'wb') as fp:
info = {
'Device Name': 'RIME Device Subset',
'Display Name': 'RIME Device Subset created on ' + str(datetime.datetime.now()),
'Product Name': 'RIME iOS Device Subset',
'Product Type': 'RIME iOS Device Subset',
}
plistlib.dump(info, fp)
log.info(f'Created {os.path.join(root, "Info.plist")}')
else:
# Copy Info.plist from template.
# TODO: There are some PII implications here.
Expand Down Expand Up @@ -309,7 +317,7 @@ def get_device_info(self) -> dict:
]
}
except plistlib.InvalidFileException:
log.error(f"Failed to read {info_plist_file}")
log.warning(f"Failed to read {info_plist_file}")
self._device_info = {}
else:
self._device_info = {}
Expand Down
10 changes: 7 additions & 3 deletions rime/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Support for GraphQL querying in RIME.
"""
import asyncio
import logging
import re
import traceback
from dataclasses import dataclass
Expand All @@ -26,6 +27,8 @@
from .provider import Provider
from .event import Event, MessageSession

logging.basicConfig(level=logging.INFO)
log = logging.getLogger(__name__)

# A per-query context which includes RIME. This is what is provided in the per-query context value.
class QueryContext:
Expand Down Expand Up @@ -480,12 +483,12 @@ def resolve_device_info(device, info):

@device_info_item_resolver.field('key')
def resolve_device_info_key(device_info_item, info):
return device_info_item[0]
return device_info_item.key


@device_info_item_resolver.field('value')
def resolve_device_info_value(device_info_item, info):
return device_info_item[1]
return device_info_item.value

# Subsetting

Expand Down Expand Up @@ -708,7 +711,8 @@ def subsets_resolver(payload, info):
RESOLVERS = [
datetime_scalar, query_resolver, event_resolver, message_event_resolver, media_event_resolver,
message_session_resolver, provider_resolver, contact_resolver, merged_contact_resolver, name_resolver,
device_resolver, mutation, devices_subscription, subsets_subscription, events_result_resolver
device_resolver, device_info_item_resolver,
mutation, devices_subscription, subsets_subscription, events_result_resolver
]


Expand Down
3 changes: 3 additions & 0 deletions rime/rime.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import asyncio
from collections import defaultdict
from dataclasses import dataclass
import logging
import os
import threading

Expand All @@ -22,6 +23,8 @@
DEVICE_CACHE = threading.local()
RIME = threading.local()

logging.basicConfig(level=logging.INFO)
log = logging.getLogger(__name__)

@dataclass(frozen=True)
class AsyncEventListener:
Expand Down

0 comments on commit e441b79

Please sign in to comment.