Don't Touch that Code!

本文探讨了软件开发流程中不同阶段服务器的角色及其访问权限的重要性。强调了开发者、QA团队及支持人员在本地开发、集成测试、验收测试及生产环境中的职责边界,并提出了合理的权限分配建议。

It has happened to everyone of us at some point. Your code was rolled on to the staging server for system testing and the testing manager writes back that she has hit a problem. Your first reaction is "Quick, let me fix that — I know what's wrong."

In the bigger sense, though, what is wrong is that as a developer you think you should have access to the staging server.

In most web-based development environments the architecture can be broken down like this:

  • Local development and unit testing on the developer's machine
  • Development server where manual or automated integration testing is done
  • Staging server where the QA team and the users do acceptance testing
  • Production server

Yes, there are other servers and services sprinkled in there, like source code control and ticketing, but you get the idea. Using this model, a developer — even a senior developer — should never have access beyond the development server. Most development is done on a developer's local machine using their favorite blend of IDEs, virtual machines, and an appropriate amount of black magic sprinkled over it for good luck.

Once checked into SCC, whether automatically or manually, it should be rolled over to the development server where it can be tested and tweaked if necessary to make sure everything works together. From this point on, though, the developer is a spectator to the process.

The staging manager should package and roll the code to the staging server for the QA team. Just like developers should have no need to access anything beyond the development server, the QA team and the users have no need to touch anything on the development server. If it's ready for acceptance testing, cut a release and roll, don't ask the user to "Just look at something real quick" on the development server. Remember, unless you are coding the project by yourself, other people have code there and they may not be ready for the user to see it. The release manager is the only person who should have access to both.

Under no circumstances — ever, at all — should a developer have access to a production server. If there is a problem, your support staff should either fix it or request that you fix it. After it's checked into SCC they will roll a patch from there. Some of the biggest programming disasters I've been a part of have taken place because someone *cough*me*cough* violated this last rule. If it's broke, production is not the place to fix it.

by Cal Evans

This work is licensed under a Creative Commons Attribution 3

void InputReader::loopOnce() { int32_t oldGeneration; int32_t timeoutMillis; // Copy some state so that we can access it outside the lock later. bool inputDevicesChanged = false; std::vector<InputDeviceInfo> inputDevices; std::list<NotifyArgs> notifyArgs; { // acquire lock std::scoped_lock _l(mLock); oldGeneration = mGeneration; timeoutMillis = -1; auto changes = mConfigurationChangesToRefresh; if (changes.any()) { mConfigurationChangesToRefresh.clear(); timeoutMillis = 0; refreshConfigurationLocked(changes); } else if (mNextTimeout != LLONG_MAX) { nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC); timeoutMillis = toMillisecondTimeoutDelay(now, mNextTimeout); } } // release lock std::vector<RawEvent> events = mEventHub->getEvents(timeoutMillis); { // acquire lock std::scoped_lock _l(mLock); mReaderIsAliveCondition.notify_all(); if (!events.empty()) { mPendingArgs += processEventsLocked(events.data(), events.size()); } if (mNextTimeout != LLONG_MAX) { nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC); if (now >= mNextTimeout) { if (debugRawEvents()) { ALOGD("Timeout expired, latency=%0.3fms", (now - mNextTimeout) * 0.000001f); } mNextTimeout = LLONG_MAX; mPendingArgs += timeoutExpiredLocked(now); } } if (oldGeneration != mGeneration) { inputDevicesChanged = true; inputDevices = getInputDevicesLocked(); mPendingArgs.emplace_back( NotifyInputDevicesChangedArgs{mContext.getNextId(), inputDevices}); } std::swap(notifyArgs, mPendingArgs); // Keep track of the last used device for (const NotifyArgs& args : notifyArgs) { mLastUsedDeviceId = getDeviceIdOfNewGesture(args).value_or(mLastUsedDeviceId); } } // release lock // Flush queued events out to the listener. // This must happen outside of the lock because the listener could potentially call // back into the InputReader's methods, such as getScanCodeState, or become blocked // on another thread similarly waiting to acquire the InputReader lock thereby // resulting in a deadlock. This situation is actually quite plausible because the // listener is actually the input dispatcher, which calls into the window manager, // which occasionally calls into the input reader. for (const NotifyArgs& args : notifyArgs) { mNextListener.notify(args); } // Notify the policy that input devices have changed. // This must be done after flushing events down the listener chain to ensure that the rest of // the listeners are synchronized with the changes before the policy reacts to them. if (inputDevicesChanged) { mPolicy->notifyInputDevicesChanged(inputDevices); } // Notify the policy of configuration change. This must be after policy is notified about input // device changes so that policy can fetch newly added input devices on configuration change. for (const auto& args : notifyArgs) { const auto* configArgs = std::get_if<NotifyConfigurationChangedArgs>(&args); if (configArgs != nullptr) { mPolicy->notifyConfigurationChanged(configArgs->eventTime); } } // Notify the policy of the start of every new stylus gesture. for (const auto& args : notifyArgs) { const auto* motionArgs = std::get_if<NotifyMotionArgs>(&args); if (motionArgs != nullptr && isStylusPointerGestureStart(*motionArgs)) { mPolicy->notifyStylusGestureStarted(motionArgs->deviceId, motionArgs->eventTime); } } } std::list<NotifyArgs> InputReader::processEventsLocked(const RawEvent* rawEvents, size_t count) { std::list<NotifyArgs> out; for (const RawEvent* rawEvent = rawEvents; count;) { int32_t type = rawEvent->type; size_t batchSize = 1; if (type < EventHubInterface::FIRST_SYNTHETIC_EVENT) { int32_t deviceId = rawEvent->deviceId; while (batchSize < count) { if (rawEvent[batchSize].type >= EventHubInterface::FIRST_SYNTHETIC_EVENT || rawEvent[batchSize].deviceId != deviceId) { break; } batchSize += 1; } if (debugRawEvents()) { ALOGD("BatchSize: %zu Count: %zu", batchSize, count); } out += processEventsForDeviceLocked(deviceId, rawEvent, batchSize); } else { switch (rawEvent->type) { case EventHubInterface::DEVICE_ADDED: addDeviceLocked(rawEvent->when, rawEvent->deviceId); break; case EventHubInterface::DEVICE_REMOVED: removeDeviceLocked(rawEvent->when, rawEvent->deviceId); break; case EventHubInterface::FINISHED_DEVICE_SCAN: handleConfigurationChangedLocked(rawEvent->when); break; default: ALOG_ASSERT(false); // can't happen break; } } count -= batchSize; rawEvent += batchSize; } return out; } std::list<NotifyArgs> InputReader::processEventsForDeviceLocked(int32_t eventHubId, const RawEvent* rawEvents, size_t count) { auto deviceIt = mDevices.find(eventHubId); if (deviceIt == mDevices.end()) { ALOGW("Discarding event for unknown eventHubId %d.", eventHubId); return {}; } std::shared_ptr<InputDevice>& device = deviceIt->second; if (device->isIgnored()) { // ALOGD("Discarding event for ignored deviceId %d.", deviceId); return {}; } //#ifdef OPLUS_EXTENSION_HOOK //yang.y.liu@Game.Joystick, 2021/07/14, Add for joystick adapter if (!getInputFlingerExt()->processEventsForDeviceLocked(device.get(), eventHubId, rawEvents, count)) { ALOGV("game code processEventsForDeviceLocked return {}"); return {}; } //#endif return device->process(rawEvents, count); } std::list<NotifyArgs> InputDevice::process(const RawEvent* rawEvents, size_t count) { // Process all of the events in order for each mapper. // We cannot simply ask each mapper to process them in bulk because mappers may // have side-effects that must be interleaved. For example, joystick movement events and // gamepad button presses are handled by different mappers but they should be dispatched // in the order received. std::list<NotifyArgs> out; for (const RawEvent* rawEvent = rawEvents; count != 0; rawEvent++) { if (debugRawEvents()) { const auto [type, code, value] = InputEventLookup::getLinuxEvdevLabel(rawEvent->type, rawEvent->code, rawEvent->value); ALOGD("Input event: eventHubDevice=%d type=%s code=%s value=%s when=%" PRId64, rawEvent->deviceId, type.c_str(), code.c_str(), value.c_str(), rawEvent->when); } if (mDropUntilNextSync) { if (rawEvent->type == EV_SYN && rawEvent->code == SYN_REPORT) { out += reset(rawEvent->when); mDropUntilNextSync = false; ALOGD_IF(debugRawEvents(), "Recovered from input event buffer overrun."); } else { ALOGD_IF(debugRawEvents(), "Dropped input event while waiting for next input sync."); } } else if (rawEvent->type == EV_SYN && rawEvent->code == SYN_DROPPED) { ALOGI("Detected input event buffer overrun for device %s.", getName().c_str()); mDropUntilNextSync = true; } else { for_each_mapper_in_subdevice(rawEvent->deviceId, [&](InputMapper& mapper) { out += mapper.process(*rawEvent); }); } --count; } postProcess(out); return out; } std::list<NotifyArgs> KeyboardInputMapper::process(const RawEvent& rawEvent) { std::list<NotifyArgs> out; mHidUsageAccumulator.process(rawEvent); switch (rawEvent.type) { //#ifdef OPLUS_FEATURE_INPUT // Xingxing.Guo@ANDROID.INPUT, 7251550, 2024/06/06, add for spruce. case EV_KEY: { int32_t scanCode = rawEvent.code; SpruceSwipEnable = false; if ((scanCode == SPRUCE_SWIP_DOWN_SCAN_CODE || scanCode == SPRUCE_SWIP_UP_SCAN_CODE) && (rawEvent.value != 0)) { SpruceSwipEnable = true; SpruceScanCode = scanCode; } else if (isSupportedScanCode(scanCode)) { out += processKey(rawEvent.when, rawEvent.readTime, rawEvent.value != 0, scanCode, mHidUsageAccumulator.consumeCurrentHidUsage()); } break; } case EV_ABS: { if (SpruceSwipEnable) { ALOGI("EV_ABS ScanCode=0x%04x SpruceSwipValue=0x%08x", SpruceScanCode, rawEvent.value); SpruceSwipValue = rawEvent.value; out += processKey(rawEvent.when, rawEvent.readTime, true, SpruceScanCode, mHidUsageAccumulator.consumeCurrentHidUsage()); SpruceSwipEnable = false; } break; } default: { SpruceSwipEnable = false; break; } //#else /* case EV_KEY: { int32_t scanCode = rawEvent.code; if (isSupportedScanCode(scanCode)) { out += processKey(rawEvent.when, rawEvent.readTime, rawEvent.value != 0, scanCode, mHidUsageAccumulator.consumeCurrentHidUsage()); } } */ //#endif OPLUS_FEATURE_INPUT */ } return out; } std::list<NotifyArgs> KeyboardInputMapper::processKey(nsecs_t when, nsecs_t readTime, bool down, int32_t scanCode, int32_t usageCode) { std::list<NotifyArgs> out; int32_t keyCode; int32_t keyMetaState; uint32_t policyFlags; int32_t flags = AKEY_EVENT_FLAG_FROM_SYSTEM; if (getDeviceContext().mapKey(scanCode, usageCode, mMetaState, &keyCode, &keyMetaState, &policyFlags)) { keyCode = AKEYCODE_UNKNOWN; keyMetaState = mMetaState; policyFlags = 0; } nsecs_t downTime = when; std::optional<size_t> keyDownIndex = findKeyDownIndex(scanCode); //#ifdef OPLUS_FEATURE_ROTATE_VOLUMEKEY //Xiaobo.Ding@ANDROID.Input 2022/09/09, Add for ROTATE_VOLUMEKEY if (mSupportRotateVolume) { keyCode = rotateVolumeKeyCode(keyCode, down); } //endif /* OPLUS_FEATURE_ROTATE_VOLUMEKEY */ if (down) { // Rotate key codes according to orientation if needed. if (mParameters.orientationAware) { keyCode = rotateKeyCode(keyCode, getOrientation()); } // Add key down. if (keyDownIndex) { // key repeat, be sure to use same keycode as before in case of rotation keyCode = mKeyDowns[*keyDownIndex].keyCode; downTime = mKeyDowns[*keyDownIndex].downTime; flags = mKeyDowns[*keyDownIndex].flags; } else { // key down if ((policyFlags & POLICY_FLAG_VIRTUAL) && getContext()->shouldDropVirtualKey(when, keyCode, scanCode)) { return out; } if (policyFlags & POLICY_FLAG_GESTURE) { out += getDeviceContext().cancelTouch(when, readTime); flags |= AKEY_EVENT_FLAG_KEEP_TOUCH_MODE; } KeyDown keyDown; keyDown.keyCode = keyCode; keyDown.scanCode = scanCode; keyDown.downTime = when; keyDown.flags = flags; mKeyDowns.push_back(keyDown); } onKeyDownProcessed(downTime); } else { // Remove key down. if (keyDownIndex) { // key up, be sure to use same keycode as before in case of rotation keyCode = mKeyDowns[*keyDownIndex].keyCode; downTime = mKeyDowns[*keyDownIndex].downTime; flags = mKeyDowns[*keyDownIndex].flags; mKeyDowns.erase(mKeyDowns.begin() + *keyDownIndex); } else { // key was not actually down ALOGI("Dropping key up from device %s because the key was not down. " "keyCode=%d, scanCode=%d", getDeviceName().c_str(), keyCode, scanCode); return out; } } if (updateMetaStateIfNeeded(keyCode, down)) { // If global meta state changed send it along with the key. // If it has not changed then we'll use what keymap gave us, // since key replacement logic might temporarily reset a few // meta bits for given key. keyMetaState = mMetaState; } DeviceId deviceId = getDeviceId(); // On first down: Process key for keyboard classification (will send reconfiguration if the // keyboard type change) if (down && !keyDownIndex) { KeyboardClassifier& classifier = getDeviceContext().getContext()->getKeyboardClassifier(); classifier.processKey(deviceId, scanCode, keyMetaState); getDeviceContext().setKeyboardType(classifier.getKeyboardType(deviceId)); } KeyboardType keyboardType = getDeviceContext().getKeyboardType(); // Any key down on an external keyboard should wake the device. // We don't do this for internal keyboards to prevent them from waking up in your pocket. // For internal keyboards and devices for which the default wake behavior is explicitly // prevented (e.g. TV remotes), the key layout file should specify the policy flags for each // wake key individually. if (down && getDeviceContext().isExternal() && !mParameters.doNotWakeByDefault && !(keyboardType != KeyboardType::ALPHABETIC && isMediaKey(keyCode))) { policyFlags |= POLICY_FLAG_WAKE; } //#ifndef OPLUS_FEATURE_INPUT_LASER //Xingxing.Guo@ANDROID.6722667, 2024/03/04, add for pad laser if (getDeviceContext().isLaserPencilDevice()) { ALOGD("Laser from device %s " "keyCode=%d, scanCode=%d", getDeviceName().c_str(), keyCode, scanCode); if (!mKeyboardConfig.oplusConfigParameters.laserEnabled) { ALOGV("Laser is not supported!"); return out; } else if (policyFlags & POLICY_FLAG_WAKE) { policyFlags &= ~POLICY_FLAG_WAKE; } } //#endif /* OPLUS_FEATURE_INPUT_LASER */ if (mParameters.handlesKeyRepeat) { policyFlags |= POLICY_FLAG_DISABLE_KEY_REPEAT; } //#ifdef OPLUS_FEATURE_INPUT // Xingxing.Guo@ANDROID.INPUT, 7251550, 2024/06/06, add for spruce. if (SpruceSwipEnable) { SpruceSwipEnable = false; when = SpruceSwipValue; } //#endif OPLUS_FEATURE_INPUT */ out.emplace_back(NotifyKeyArgs(getContext()->getNextId(), when, readTime, deviceId, mSource, getDisplayId(), policyFlags, down ? AKEY_EVENT_ACTION_DOWN : AKEY_EVENT_ACTION_UP, flags, keyCode, scanCode, keyMetaState, downTime)); //#ifdef OPLUS_EXTENSION_DEBUG //luochuang@ANDROID.INPUT, 2021/05/25, saupwkProcessKey feature extern void __attribute__((weak)) saupwkProcessKey(int32_t scanCode, bool down); if(saupwkProcessKey) { ALOGV("theia start saupwkProcessKey"); saupwkProcessKey(scanCode, down); } //#endif /* OPLUS_EXTENSION_DEBUG */ return out; } 这几段代码是获取按键亮屏中的部分,请告诉我每一个函数在其中的作用以及关键代码解释,在 KeyboardInputMapper::processKey最后的out返回到inputreader之后又要怎么执行,请基于安卓15源码正确详细讲解
09-19
本系统采用Python编程语言中的Flask框架作为基础架构,实现了一个面向二手商品交易的网络平台。该平台具备完整的前端展示与后端管理功能,适合用作学术研究、课程作业或个人技术能力训练的实际案例。Flask作为一种简洁高效的Web开发框架,能够以模块化方式支持网站功能的快速搭建。在本系统中,Flask承担了核心服务端的角色,主要完成请求响应处理、数据运算及业务流程控制等任务。 开发工具选用PyCharm集成环境。这款由JetBrains推出的Python专用编辑器集成了智能代码提示、错误检测、程序调试与自动化测试等多种辅助功能,显著提升了软件编写与维护的效率。通过该环境,开发者可便捷地进行项目组织与问题排查。 数据存储部分采用MySQL关系型数据库管理系统,用于保存会员资料、产品信息及订单历史等内容。MySQL具备良好的稳定性和处理性能,常被各类网络服务所采用。在Flask体系内,一般会配合SQLAlchemy这一对象关系映射工具使用,使得开发者能够通过Python类对象直接管理数据实体,避免手动编写结构化查询语句。 缓存服务由Redis内存数据库提供支持。Redis是一种支持持久化存储的开放源代码内存键值存储系统,可作为高速缓存、临时数据库或消息代理使用。在本系统中,Redis可能用于暂存高频访问的商品内容、用户登录状态等动态信息,从而加快数据获取速度,降低主数据库的查询负载。 项目归档文件“Python_Flask_ershou-master”预计包含以下关键组成部分: 1. 应用主程序(app.py):包含Flask应用初始化代码及请求路径映射规则。 2. 数据模型定义(models.py):通过SQLAlchemy声明与数据库表对应的类结构。 3. 视图控制器(views.py):包含处理各类网络请求并生成回复的业务函数,涵盖账户管理、商品展示、订单处理等操作。 4. 页面模板目录(templates):存储用于动态生成网页的HTML模板文件。 5. 静态资源目录(static):存放层叠样式表、客户端脚本及图像等固定资源。 6. 依赖清单(requirements.txt):记录项目运行所需的所有第三方Python库及其版本号,便于环境重建。 7. 参数配置(config.py):集中设置数据库连接参数、缓存服务器地址等运行配置。 此外,项目还可能包含自动化测试用例、数据库结构迁移工具以及运行部署相关文档。通过构建此系统,开发者能够系统掌握Flask框架的实际运用,理解用户身份验证、访问控制、数据持久化、界面动态生成等网络应用关键技术,同时熟悉MySQL数据库运维与Redis缓存机制的应用方法。对于入门阶段的学习者而言,该系统可作为综合性的实践训练载体,有效促进Python网络编程技能的提升。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
在当代储能装置监控技术领域,精确测定锂离子电池的电荷存量(即荷电状态,SOC)是一项关键任务,它直接关系到电池运行的安全性、耐久性及整体效能。随着电动车辆产业的迅速扩张,业界对锂离子电池SOC测算的精确度与稳定性提出了更为严格的标准。为此,构建一套能够在多样化运行场景及温度条件下实现高精度SOC测算的技术方案具有显著的实际意义。 本文介绍一种结合Transformer架构与容积卡尔曼滤波(CKF)的混合式SOC测算系统。Transformer架构最初在语言处理领域获得突破性进展,其特有的注意力机制能够有效捕捉时间序列数据中的长期关联特征。在本应用中,该架构用于分析电池工作过程中采集的电压、电流与温度等时序数据,从而识别电池在不同放电区间的动态行为规律。 容积卡尔曼滤波作为一种适用于非线性系统的状态估计算法,在本系统中负责对Transformer提取的特征数据进行递归融合与实时推算,以持续更新电池的SOC值。该方法增强了系统在测量噪声干扰下的稳定性,确保了测算结果在不同环境条件下的可靠性。 本系统在多种标准驾驶循环(如BJDST、DST、FUDS、US06)及不同环境温度(0°C、25°C、45°C)下进行了验证测试,这些条件涵盖了电动车辆在实际使用中可能遇到的主要工况与气候范围。实验表明,该系统在低温、常温及高温环境中,面对差异化的负载变化,均能保持较高的测算准确性。 随附文档中提供了该系统的补充说明、实验数据及技术细节,核心代码与模型文件亦包含于对应目录中,可供进一步研究或工程部署使用。该融合架构不仅在方法层面具有创新性,同时展现了良好的工程适用性与测算精度,对推进电池管理技术的进步具有积极意义。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
代码转载自:https://pan.quark.cn/s/9e296fe8986c 实验题目为“复杂模型机的设计与实现”。 _1. 实验目的与要求:目的:1. 熟练掌握并达成较为复杂的计算机原理。 2. 本实验增加了16条机器指令,全面运用所学的计算机原理知识,借助扩展的机器指令设计并编写程序,然后在CPU中执行所编写的程序。 要求:依照练习一和练习二的要求完成相应的操作,并上机进行调试和运行。 2. 实验方案:……实验报告的标题设定为“广东工业大学计组实验报告复杂模型机的设计与实现六”,主要围绕计算机组成原理中的复杂模型机设计和实现展开。 实验的宗旨在于让学生深入理解和实际操作计算机原理,特别是通过增加16条机器指令,来全面运用所学知识设计程序,并在CPU中运行这些程序。 实验的具体要求包括:1. 掌握复杂的计算机工作原理,这要求学生不仅具备扎实的理论知识,还需要拥有将理论转化为实际操作的能力。 2. 实验中增加了16条机器指令,这涉及到计算机指令集的扩展和设计,可能包含算术运算、逻辑运算、数据传输和控制流程等指令。 3. 学生需要运用扩展的机器指令编写程序,并通过CPU进行运行和调试,这涉及到编程、汇编和CPU执行流程的理解。 4. 依照练习一和练习二的要求完成操作,这表明实验包含分阶段的练习任务,需要逐步完成并验证。 实验方案包括:1. 实验连线:保证硬件连接准确无误,这是任何电子实验的基础,对于计算机实验,这通常涵盖CPU、内存、输入/输出设备等组件的连接。 2. 实验程序:提供了范例程序,包括机器指令程序和微指令程序的微代码。 这部分内容展示了如何利用扩展的机器指令编写程序,以及对应的微指令实现,有助于理解计算机内部的低级操作。 在实验结果和数据处理部分,学生需要:1. 在程...
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值