将System.out.println或stdout数据捕获到摆动备忘录(巨大数据)(Capturing System.out.println or stdout data to a swing memo (Huge Data))
嗨我需要显示在备忘录而不是使用System.out.println结果,但不可能将标准输出放在列表中例如,并在摆动备忘录中显示此列表的内容后,因为我需要显示每一行的结果是实时还是显示。
我认为这些东西像System.out.println的观察者那样工作,当控制台中打印了一些数据或信息时,我希望能够捕获它并显示在备忘录中。
为了更好的理解,我在unix服务器中远程执行一些命令,并在标准输出中检索这些命令的结果,并计算一些时间和度量值,当然我需要这样做来模拟远程应用程序的行为。
该解决方案可以用于在备忘录中显示清单中每一行或每个项目的完整时间。
而秋千备忘录可以处理大于500kb或大于1MB的大字符串?
因为打印在我ID中的sdtout中的整个结果非常巨大。
谢谢
Hi I need to show the result in a memo instead using System.out.println, but isn't possible to put the stdout in a list for example and after display the contents of this list in swing memo because I need to display every line of the result in real time or when it is showed.
I'm think in something that works like an observer of System.out.println and when some data or information have been printed in the console I want to be able to capture it and display in a memo.
For a better comprehension, I execute some commands remotely in an unix server and retrieve the results of these commands in the stdout and compute some time and metrics with them, and definitely I need to do in this way to simulate the behavior of an remote application.
The solution could be a way to show every line or every item in the list in the memo in the exactly time that it is produced.
And the swing memo can deal with big strings, more than 500kb or more than 1MB?
Because the entire result printed in the sdtout in my ID is really huge.
Thx
原文:https://stackoverflow.com/questions/6316272
最满意答案
SessionMiddleware的第三行调用一个特定的会话引擎 ,它决定了要使用哪个SessionStore。
如果您进入contrib / sessions / backends / base.py,您将看到以下代码:
class SessionBase(object): ... def __getitem__(self, key): return self._session[key] def _get_session(self, no_load=False): """ Lazily loads session from storage (unless "no_load" is True, when only an empty dict is stored) and stores it in the current instance. """ self.accessed = True try: return self._session_cache except AttributeError: if self._session_key is None or no_load: self._session_cache = {} else: self._session_cache = self.load() return self._session_cache _session = property(_get_session)
它所做的是创建一个会话代理对象,中间件已附加到该请求。 它不会从数据库加载会话对象,直到您说出:
x = request.session['key']
此时,
__getitem__(self, key)
self._session
__getitem__(self, key)
试图解引用self._session
,它(作为属性)反过来返回此事务的会话字典的缓存副本,或者如果没有可用的缓存,则从存储中获取它使用load()
方法。load()
方法由特定的子引擎实现:数据库,文件,缓存,缓存+数据库等。
SessionStore
是一个完整会话的轻量级代理; 当您需要读取或写入与会话ID cookie中编码的密钥关联的会话对象的数据时,它只会变成一个完整的会话,触及数据库。The third line of SessionMiddleware invokes a specific session engine, which dictates which SessionStore to use.
If you go down into contrib/sessions/backends/base.py, you'll see the following code:
class SessionBase(object): ... def __getitem__(self, key): return self._session[key] def _get_session(self, no_load=False): """ Lazily loads session from storage (unless "no_load" is True, when only an empty dict is stored) and stores it in the current instance. """ self.accessed = True try: return self._session_cache except AttributeError: if self._session_key is None or no_load: self._session_cache = {} else: self._session_cache = self.load() return self._session_cache _session = property(_get_session)
What this does is create a session proxy object, which the middleware has attached to the request. It does not load the session object from the database until you say:
x = request.session['key']
At which point, the
__getitem__(self, key)
attempts to dereferenceself._session
, which (being a property) in turn returns a cached copy of the session dictionary for this transaction, or if no cache is available, fetches it from the store using theload()
method. Theload()
method is implemented by specific child engines: database, file, cache, cache + db, etc.
SessionStore
is a lightweight proxy for a full session; it only becomes a full session, hitting the database, when you need to read or write data to the session object associated with the key encoded in the session id cookie.
相关问答
更多-
检查会话是否存在(Check for existence of sessions)[2021-09-28]
如果您的意思是“如何查看所有会话”,这取决于所使用的会话存储机制。 您通常可以在/ tmp中找到存储为单个文件的基于文件的会话数据(或者更确切地说,如果session.save_handler是'files',则路径由session.save_path设置) 如果您的意思是“我怎样才能看到会话中的所有变量”,您可以使用foreach foreach($_SESSION as $name=>$value) { echo "$name = $value
"; } If you mean, "h ... -
简单的回答: 没有办法完成你的要求。 不同的RDBMS以不同的方式表示模式,表,权限和数据字典。 更大的答案:提出问题的实体需要知道它所查询的RDBMS。 然后可以为所讨论的数据库系统形成表存在问题。 即使有了这些信息,@ dat_hinrik也是正确的,权限可能会阻止您查看现有表。 Simple answer: there's not a way to accomplish what you are requesting. Different RDBMSs represent schemas, table ...
-
SessionMiddleware的第三行调用一个特定的会话引擎 ,它决定了要使用哪个SessionStore。 如果您进入contrib / sessions / backends / base.py,您将看到以下代码: class SessionBase(object): ... def __getitem__(self, key): return self._session[key] def _get_session(self, no_load=False ...
-
Flask - 像使用cookie一样将会话数据保存在数据库中(Flask - Save session data in database like using cookies)[2022-04-11]
我建议你通过继承瓶子默认值来实现你自己的Session和SessionInterface。 基本上,你需要定义你自己的会话类和会话接口类。 class MyDatabaseSession(CallbackDict, SessionMixin): def __init__(self, initial=None, sid=None): CallbackDict.__init__(self, initial) self.sid = sid self.mod ... -
通过添加sqlite数据库的绝对路径来解决此问题。 settings.py产生了错误: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'expofit_database', ... ... 新的settings.py: PROJECT_PATH = os.path.realpath(os.path.dirname(_ ...
-
您可以编写一个方法来获取id并使用SqlCommand来执行查询: public bool ItemExists(int id) { using (var conn = new SqlConnection("YOUR CONNECTION STRING")) using (var cmd = conn.CreateCommand()) { conn.Open(); cmd.CommandText = "SELECT count(*) FROM some ...
-
Django对象存在(Django object existence)[2021-11-03]
通常你会使用get_or_create 。 model_instance = MyModel.objects.get_or_create(surname='foo') 你不应该真的使用management.call_command的东西。 也就是说,如果我误解了你并且你有充分的理由,试试这个: try: MyModel.objects.get(surname='foo') except MyModel.DoesNotExist: management.call_command(.... ... -
试试动态查询: Declare @tablename varchar(100) = 'testtable', @dbName Varchar(100) = 'TestDB' DECLARE @statement NVARCHAR(MAX) = 'If exists (select * from ' + @dbName + '..sysobjects where name = ''' + @tablename + ''')' + 'Print ''Table Exists''' + 'Else Print ...
-
是的,它确实。 如果您查看源文档字符串,请明确说明: def flush(self): """ Removes the current session data from the database and regenerates the key. """ self.clear() self.delete() self._session_key = None 话虽如此,将会有过期会话的积累。 这就是为什么你应该使用clearsessions管理命令设置 ...
-
手册 : PDO::query()返回PDOStatement对象, 失败时返回FALSE 。 您的查询是有效的,永远不会失败(忽略可能的较低级别问题)。 $result将始终评估为TRUE -ish,因此流将始终进入if ($result)块。 ( if (empty($result))几乎没有任何意义) 您需要检查查询是否返回零行 (零结果不是错误)。 第二个想法 : 如果关联的PDOStatement执行的最后一个SQL语句是SELECT语句,则某些数据库可能会返回该语句返回的行数。 但是, 并不是所 ...